ACTIVITY
Timeline
Timeline for the post: Node.js worker_threads hang under high CPU when using SharedArrayBuffer + Atomics.notify in clustered app
Currently licensed under: CC BY-SA 4.0
| When | What | By | License | Comment |
|---|---|---|---|---|
Oct 22, 2026, 9:30:52 AM 1mo ago | Answer | feliciafix | CC BY-SA 4.0 | If using Atomics.wait/notify, the most common mistake is a lost wakeup: notify happens before wait is sleeping or using a different index. First, ensure every waiter uses the exact same TypedArray and index and implement a sequence counter so notifyers loop until the expected sequence is observed. Second, never block the thread that's responsible for notifying; blocking native work can starve notifications under CPU pressure. If reliability matters more than raw latency, switch to worker.postMessage() between threads or use Atomics.wait with a bounded timeout and fallback async checks. Verify by creating a small stress test reproducing the hang; if it still happens capture thread stacks with --inspect and reduce to a minimal repro before changing Node versions. Rollback by reverting to message-passing if SAB changes worsen behavior. |
Oct 22, 2026, 9:30:52 AM 1mo ago | Created | pixelpelle | CC BY-SA 4.0 | Node.js worker_threads hang under high CPU when using SharedArrayBuffer + Atomics.notify in clustered app |