-
Notifications
You must be signed in to change notification settings - Fork 200
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
util.sleep is only available inflight #5418
Comments
Can you share more details about the use case? |
in this particular case wanted to do testing (generating a batch of ulids in preflight). What's the reasoning for it being inflight only? |
It's a technical limitation. Preflight is sync while inflight is async. In JavaScript, synchronously sleeping is not really a thing, so sleeping during preflight is a bit tricky to implement (one can implement this with |
If we're running preflight code in a worker thread it could also be possible to sleep using the Atomics API: const sleep = milliseconds => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
sleep(5000); |
I tried this:
use
util.sleep
in preflightThis happened:
only available inflight
I expected this:
use it preflight
Is there a workaround?
was trying to use util.shell - but can't due to #5417
Anything else?
No response
Wing Version
main branch
Node.js Version
18.7
Platform(s)
MacOS
Community Notes
The text was updated successfully, but these errors were encountered: