Repository navigation
Description
What happened?
Since #1029 put --test-force-exit on npm test, the Tests (windows-latest) job hangs in npm test until the 20-minute job limit cancels it. Both hangs looked at are the same file: test/sandbox-blocked.test.js never ends.
- All eleven tests in the file pass, together in under a second. The file's process then stays alive: 1085 s and 1092 s until the cancel.
- Every other unit file passes (4114 and 4123 of them). The 107 files listed under Interrupted while running are just the ones after
sandbox-blockedin alphabetical order: they ran, but the reporter prints files in order and was waiting for this one. - Windows only. On macOS the same file with the same flags ended in under a second 30 times out of 30.
- Not the environment: Node 24.21.0 and runner image
windows-2025-vs2026/20261002.596in the green runs and in the hanging ones alike. Notnode_moduleseither: nothing of it is tracked,npm citakes its usual ~17 s, and the generated-file check reads onlysrc/preloadandsrc/shared. - Not tied to one branch: it hung on
claude/gitignore-node-modules-symlink(run 38951875833, twice) and onclaude/mach-noch-1013-fcd6d3(run 38953242527, Fix the low-severity robustness and usability findings of AR-38 (#1013) #1031).
Windows npm test over 2026-10-15/16: 37 runs before #1029 all green, then 3 green and 3 hanging.
Working hypothesis, not proven. With --test-force-exit the root test in the child does not call process.exit() straight away: it waits for each reporter destination, that is its own stdout pipe, to emit 'unpipe' and close first (lib/internal/test_runner/test.js). The parent waits for the child's exit and for finished(child.stdout), with no per-file limit (runner.js). If that 'unpipe' never comes on a Windows pipe while something keeps the child's loop alive, the file never ends. Why this file and not the 76 others that use the same happy-dom helper is open.
Steps to reproduce
- Push any branch based on
mainafterd798320(Put time limits on the test runs and the CI job (#997) #1029). - Watch
Tests (windows-latest)→ Run npm test. Not every run hangs (3 of the last 6 did).
Expected behaviour
npm test on Windows ends in its usual ~2 minutes, and a file whose tests are through ends with them.
Mitigation in place
--test-force-exit is taken off npm test (see the pull request that references this issue); test:e2e keeps it, because the hang #997 was about is an E2E one. This issue is about the cause, so the flag can come back to the unit suite — or stay off for a reason we know.
What to find out
- A diagnostic run on Windows:
test/sandbox-blocked.test.jsalone, many times in a row, with and without--test-force-exit— does only the flag make it hang? - When it hangs: what keeps the child alive — a handle dump (
process.getActiveResourcesInfo()from a timer in the file, orwhy-is-node-running), and whether the child has exited while its stdout stays open. - Whether
withDom()not awaiting happy-dom'swindow.close()matters here (it returns a promise in happy-dom 20.14.5). - If it is Node's force-exit path: a minimal repro and a report upstream; if it is ours: the fix in the file or the helper.
- Decide whether
npm testgets--test-force-exitback, and update the table under Time limits indocs/test-concept.md.
App version
Not app-related: test runner on CI, main from d798320 on.
Operating system
Windows (GitHub runner windows-latest, image windows-2025-vs2026 20261002.596), Node 24.21.0.
Logs / screenshots
From run 38953242527, job Tests (windows-latest):
✖ test\sandbox-blocked.test.js (1092833.9159ms)
'Promise resolution is still pending but the event loop has already resolved'
##[error]The operation was canceled.
Activity
Run the unit suite without --test-force-exit (#1038) (#1039)
kkrafft1999 commentedon Oct 16, 2026
Upstream: a known
--test-force-exitbug, and what it means hereA separate analysis (done locally on macOS, Node v24.18.1) found an open upstream bug in Node's test runner:
--test-force-exitwith concurrency silently loses test verdicts: open since 2026-07-30, reported for 22.x, 24.x and 26.x.needs-ci. Not in any release (both checked 2026-10-16).The upstream symptom is not ours. With
--test-force-exitthe child callsprocess.exit()while results are still queued for the stdout pipe. On Linux and macOS pipe writes are asynchronous, so the tail is lost. The runner then reports fewer tests than ran, with exit code 0. The earlier fix (nodejs/node#55099) only waits for reporter destinations that have aclose()method, and a pipe has none. On Windows pipe writes are synchronous (A note on process I/O), so nothing is lost there. We see the opposite: Windows only, nothing lost, the file never ends.Why it matters for this issue anyway: a lead, not a proof. The same synchronous pipe write on Windows is a candidate mechanism for the hang. A child writing synchronously to its stdout pipe blocks until the runner reads. If that read stalls at the end of
sandbox-blocked.test.js, the child never reachesprocess.exit(), and the runner waits forexitandfinished(child.stdout)with no per-file limit. Worth checking in the diagnostic run:--test-isolation=none(no child, no pipe)? That would separate pipe-related causes from the file itself.repro.mjs— four variants of one file with N trivial testsOn macOS: 8 of 15 runs with
--test-force-exitlost 5 to 58 of 10,000 results; with the preload 15/15 and with--test-isolation=none5/5 were complete; without the flag 15/15 were complete. At 40 files × 50 tests nothing was lost. The bug depends on timing and on the amount of output.Remaining risk where the flag is still on.
npm run test:e2ekeeps--test-force-exitand runs on Linux and macOS, which is where the upstream bug bites. The gate itself holds: a lost failing verdict still leaves the child with exit code 1, so the run stays red, though the test's name and message may be missing from the report. Lost passing verdicts only shrink the count. With 36 E2E tests and little output the odds are small. They grow with output.Workarounds upstream names, for reference.
process.stdout._handle?.setBlocking?.(true)via--require). This is what #64875 does internally, but it relies on a private API.--test-isolation=none. It changes how the suite runs: shared globals, module cache and mocks.Neither is proposed here. The unit suite runs without the flag since #1039.
test:e2ekeep it? Update the Time limits table indocs/test-concept.mdaccordingly.kkrafft1999 commentedon Oct 17, 2026
Cause found: a Node 24 deadlock in
process.exit(), not a leaked handleChecked on 2026-10-17, macOS, Node v24.18.1.
It is not Windows-only. Running
node --test --test-force-exit test/sandbox-blocked.test.jsfour at a time, 5 of 150 runs hung on macOS as well. Without the flag 0 of 16 hung; the control filetest/tool-log-view-dom.test.jswith the flag 0 of 24.What a hung child does. It sits at 0 % CPU in state
S. Its timers never fire, and it does not answer--report-on-signaleither. The main thread is blocked, so the in-process diagnostics proposed above cannot see it. A native stack fromsamplecan:process.exit()→node::Environment::Exit→DisposePlatform→NodePlatform::Shutdown→WorkerThreadsTaskRunner::Shutdown→uv_thread_joinV8Workerthreads:MaglevConcurrentDispatcher::JobTask::Run→MaglevCompiler::Compile→ … →HeapAllocator::AllocateRawWithRetryOrFailSlowPath→CollectionBarrier::AwaitCollectionBackground--test-force-exitcallsprocess.exit()the moment the last test is through. In that window a background Maglev compile is still running. It needs a garbage collection that only the main thread can run, and the main thread is waiting to join it. A natural exit disposes the isolate first, so it never meets this.Upstream: nodejs/node#64274 Hang at shutdown (open), fix in nodejs/node#66171 src: fix hang when joining workers in process.exit() (open, not released). Node 24 turned Maglev and concurrent Sparkplug on, which is what made this reachable.
Workaround, measured: with
--no-maglev --no-concurrent-sparkplug0 of 150 runs hung (same setup as the 5 of 150). The test runner hands the flags on to each file's process.Why this file: it ends right after its heaviest happy-dom tests, so JIT work is still in flight when
process.exit()comes. That matches the upstream reports (process.exit right after a burst of work, worse on a loaded host). The open questions from the description, answered:withDom()not awaitingwindow.close(): unrelated.Keep --test-force-exit out of the Node 24 exit deadlock (#1038) (#1053)