-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
Atomic.waitAsync never wakes #44729
Comments
Not sure if a node workers or V8 atomics issue. @nodejs/workers @nodejs/v8 |
It seems like the worker dies while waiting for atomics? |
It's not that it doesn't wake, it's that it stop running. If I add a |
I had a little play around, the reason this is happening is because nothing is keeping the thread alive. Usually for a worker_thread having: import { parentPort } from "node:worker_threads";
parentPort.on("message", () => { /* ... */ }); would keep the worker alive because This is why There is in fact already an open pr to make In the meantime just use |
We were actually wondering if it is necessary for the host to keep the thread alive for the timeout in https://bugs.chromium.org/p/v8/issues/detail?id=13238 (this is not specified and host-defined, so technically Node.js does not have to keep the thread alive - i.e. this would be a wontfix). If you have a use case that cannot be solved by the manually reffing/unreffing solution mentioned above, or that can be error-prone with the manual solution, it would be appreciated to drop a comment in the V8 issue about the use case (the feature is still in stage 3 and it would be good to have a bit more investigation into this issue). |
@Jamesernator suggestion works for us. I'll leave this open for a little bit for visibility but feel free to close it. |
I think it's certainly surprising given that this is the only async operation that doesn't keep the thread alive. If anyone else does a similar pattern to the original problem here, i.e. use Even if v8 doesn't change anything, it might be sufficient just to put some documentation in |
Closing in favor of #44409 |
See repro https://github.com/ronag/waitAsync-wake-repro
Seems like
Atomic.waitAsync
sometimes never wakes, even if provided with a timeout.The text was updated successfully, but these errors were encountered: