Skip to content

Commit b992d67

Browse files
kkrafft1999claude
andauthored
Keep --test-force-exit out of the Node 24 exit deadlock (#1038) (#1053)
The Windows hang of test/sandbox-blocked.test.js was no leaked handle: process.exit() from --test-force-exit deadlocks in DisposePlatform when a background Maglev compile is waiting for a main-thread GC (nodejs/node#64274, fix pending in nodejs/node#66171). It reproduces on macOS too: 5 of 150 runs hung, 0 of 150 with --no-maglev --no-concurrent-sparkplug. The unit suite stays without the flag, now for a known reason. The E2E suite keeps it and gets the two V8 flags, which only reach the runner's Node processes, not the Electron app under test. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent bf09e08 commit b992d67

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

‎docs/test-concept.md‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ push, everything runs.
5656
A test that hangs must fail, not hold the gate. On 2026-10-15 a failed E2E test
5757
on Linux left its process running and the required check waited six hours for
5858
GitHub to cancel it ([#997](https://github.com/kkrafft1999/snotra/issues/997)).
59-
Four settings stand in the way of that now:
59+
Five settings stand in the way of that now:
6060

6161
| Limit | Where | Value | What it catches |
6262
| --- | --- | --- | --- |
6363
| Per test, unit suite | `npm test`: `--test-timeout` | 120 s | A test or a `t.after` hook that never settles |
6464
| Per test, E2E suite | `npm run test:e2e`: `--test-timeout` | 300 s | The same for the app tests, above their own budgets of 60–240 s |
6565
| End of the file | `npm run test:e2e`: `--test-force-exit` | — | A file whose tests are done but which a leaked handle — a server, a child process, a timer — keeps alive |
66+
| Exit without deadlock | `npm run test:e2e`: `--no-maglev --no-concurrent-sparkplug` | — | `--test-force-exit` itself hanging in `process.exit()` on Node 24 (#1038) |
6667
| Per CI job | `ci.yml`: `timeout-minutes` | 20 min | Whatever hangs outside a test: setup, `npm ci`, code at the top level of a test file |
6768

6869
How they work together:
@@ -76,15 +77,32 @@ How they work together:
7677
waiting for is still pending, and the file runs forever. `--test-force-exit`
7778
ends each file once its tests are through; without it the per-test limit
7879
marks the test red and the job still hangs.
79-
- **The unit suite runs without `--test-force-exit`.** On Windows the flag
80-
made `test/sandbox-blocked.test.js` hang after its last test, in three of
81-
six runs: the file's tests were through, its process never ended, and the
82-
job limit cancelled it after 20 minutes (#1038). Without the flag the unit
83-
suite ended in every one of the 37 Windows runs before #1029; a test that
84-
hangs is still cut off by `--test-timeout`, and the job limit catches the
85-
rest. The E2E suite, where
86-
the hang of #997 happened, keeps the flag. Whether the unit suite gets it
87-
back is #1038's question.
80+
- **`--test-force-exit` can hang by itself on Node 24.** It ends a file by
81+
calling `process.exit()` the moment the last test is through. That call
82+
joins V8's background threads without tearing the isolate down first. If a
83+
background JIT compile (Maglev or Sparkplug) is waiting for a garbage
84+
collection at that moment, it waits for the main thread, the main thread
85+
waits for it, and the process never ends
86+
([nodejs/node#64274](https://github.com/nodejs/node/issues/64274), fix
87+
pending in [nodejs/node#66171](https://github.com/nodejs/node/pull/66171)).
88+
This was the hang of `test/sandbox-blocked.test.js` on Windows in three of
89+
six runs: its tests were through, and its process sat in `uv_thread_join`
90+
(#1038). The hang is not specific to Windows. On macOS, with four runs at a
91+
time, 5 of 150 runs of that file hung. With `--no-maglev
92+
--no-concurrent-sparkplug` none of 150 did (measured 2026-10-17). A hung
93+
process runs no timers and ignores `--report-on-signal`; only a native stack
94+
(`sample`, `gdb`) shows where it is.
95+
- **So the unit suite runs without `--test-force-exit`.** No unit file has
96+
leaked a handle, so it gains nothing from the flag and would only carry the
97+
deadlock. A test that hangs is still cut off by `--test-timeout`, and the
98+
job limit catches the rest. Without the flag the unit suite ended in every
99+
one of the 37 Windows runs before #1029.
100+
- **The E2E suite keeps it, with the two V8 flags.** The hang of #997 happened
101+
there, so the flag stays. `--no-maglev --no-concurrent-sparkplug` turn off
102+
the two JIT tiers that take part in the deadlock. The runner passes them on
103+
to every test file's process. They apply to the Node processes of the test
104+
runner only: the app under test is Electron and never sees them. Drop them
105+
once a Node 24 release carries nodejs/node#66171.
88106
- **The job limit is a backstop, not a budget.** A green job takes three to
89107
five minutes (30 green runs up to 2026-10-16: at most 311 s on macOS, 287 s
90108
on Windows, 180 s on Linux). Twenty minutes leaves room for a slow runner

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"pretest": "node scripts/sync-renderer-vendor.js",
1010
"test": "node --no-use-system-ca --test --test-timeout=120000 \"test/**/*.test.js\"",
1111
"pretest:e2e": "node scripts/sync-renderer-vendor.js",
12-
"test:e2e": "node --no-use-system-ca --test --test-timeout=300000 --test-force-exit e2e/*.test.mjs",
12+
"test:e2e": "node --no-use-system-ca --no-maglev --no-concurrent-sparkplug --test --test-timeout=300000 --test-force-exit e2e/*.test.mjs",
1313
"precoverage": "node scripts/sync-renderer-vendor.js",
1414
"coverage": "node scripts/coverage.js",
1515
"start": "npm run sync-vendor && unset ELECTRON_RUN_AS_NODE && electron .",

0 commit comments

Comments
 (0)