Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Support 'await' operator in JS scripts. #1504

Open
rjamesnw opened this issue Feb 5, 2025 · 0 comments
Open

[Feat]: Support 'await' operator in JS scripts. #1504

rjamesnw opened this issue Feb 5, 2025 · 0 comments

Comments

@rjamesnw
Copy link

rjamesnw commented Feb 5, 2025

Is your feature request related to a problem? Please describe.
I have a script that I made that allows me to use await but I keep having to wrap it:

return (async ()=>{ var result = await ... });

Then I have to do this, which seems silly:
Image

But if .run() already returns a promise, when why am I not able to use 'await' in the script body? Seems the code is node being run in an async function even though a promise is being used.

Describe the solution you'd like
Be consistent, if .run() returns a promise, allow await operators in the script body by using async functions.

Describe alternatives you've considered
One ay is to run sync code to run async, so

doIt();
return;
async function doIt() { ... await ... }

Which is just silly, since .run() runs it async anyhow. Also, that way is no good if you want to return a value.

The best alternative way that works so far:

return (async ()=>{
 .... await stuff ...
})();

Seems if I return a promise at least the system detects it and that works for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant