| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
There was a problem hiding this comment.
Replacing global-scope ES builtins with proxies is a big no-no. Resolving the issues in #44409 will be the correct way forward.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #61941.
Pending Atomics.waitAsync() operations now keep the Node.js event loop alive until they settle, so the process does not exit early when the wait is the only pending async operation.
Problem
Atomics.waitAsync() returns a promise-like result, but that pending wait did not ref the event loop.
If nothing else was ref'd, Node could terminate before Atomics.notify() (or timeout) resolved the wait.
This affects real-world patterns like multithreaded WASM / Emscripten where completion is signaled via atomics from non-libuv worker activity.
Approach
Introduced internal/atomics/wait_async with trackWaitAsyncResult(result):
Integrated this in two places:
lib/internal/bootstrap/node.js
Wrap globalThis.Atomics.waitAsync so userland calls are tracked.
lib/internal/worker/messaging.js
Wrap internal primordial AtomicsWaitAsync usage so postMessageToThread() also keeps the loop alive while awaiting the shared-status wait.
Tests
Added regression coverage:
test/parallel/test-atomics-waitasync-event-loop.mjs
test/parallel/test-worker-messaging-event-loop-ref.mjs
Notes
This is a Node-side lifecycle fix around the V8-provided waitAsync result, preserving existing API behavior while correcting event-loop liveness semantics.