[Feature Request] Invoke-UDJavaScript does not return async promises

Product: PowerShell Universal
Version: 2026.1.0

Listed as Feature Request as I’m pretty certain this behaviour is currently expected, but from my opinion should be changed or modified.

When using Invoke-UDJavaScript, async operations such as promises are not waited upon for return.
Instead PSU continues to the next line of code while Invoke-UDJavaScript has yet to be resolved.
E.g.
Selecting a directory in dialog:

$path = Invoke-UDJavaScript -JavaScript “showDirectoryPicker()”
or

$path = Invoke-UDJavaScript -JavaScript @"

(async () => {

let data = await showDirectoryPicker()

return data; 

})();

"@

The ability to wait for return on async operations would greatly expand the abilities of creating custom solutions with the PSU and the use of JavaScript.
Having a switch on Invoke-UDJavaScript, such as -Wait, would be a good solution for this.

1 Like