Skip to content

test: force mocha to exit so a leaked handle cannot hang CI - #124

Merged
petersalomonsen merged 2 commits into
masterfrom
test-exit-on-hang
Aug 22, 2026
Merged

petersalomonsen merged 2 commits into
masterfrom
test-exit-on-hang

Conversation

@petersalomonsen

Copy link
Copy Markdown
Owner

What happened

The Publish job on a91915a (run 32522680732) sat for 6 hours and was killed by GitHub's hard limit.

The trigger was a transient network failure, not a code problem. test/nodefs.spec.js clones wasm-git from github.com over the real internet, and that transfer died at 68%:

net 68% ( 247 kb,   476/  699)  /  idx  40% (  285/  699)
Bad news:
 could not read from remote repository
ERROR 12: could not read from remote repository

The ErrnoError errno 44 mocha reported is just the follow-on ENOENT from FS.chdir() into a clone directory that was never created. The CI workflow on the same commit passed in 6m27s, running the same node suite — so this was a flake, not a regression.

The damage came afterwards: mocha printed 13 passing, 1 failing and then never exited. The aborted clone leaves a live handle in the emscripten module, and with no .mocharc and no --exit the event loop never drains. The job held a runner until the 6-hour cap, ending in Terminate orphan process: pid (12095) (npm run test).

The change

--exit on the two mocha scripts, so the process terminates once the run is over regardless of what handles third-party code left behind.

Verification

A probe that leaks a listening socket and throws, run under a 10-second cap:

exit code
mocha 124 — killed by the cap, still hanging
mocha --exit 1 — exits immediately, failure preserved

Both node suites still pass: npm test (14) and npm run test-opfs-detect (8).

Scope

This treats the symptom. The handle leak in the aborted clone, and the fact that nodefs.spec.js depends on reaching github.com at all, are both still there — worth a retry wrapper or a local fixture if that test keeps flaking. What this buys is that a hang becomes an immediate visible failure instead of an occupied runner.

Complements #122, which caps every job at timeout-minutes: 30.

🤖 Generated with Claude Code

petersalomonsen and others added 2 commits August 22, 2026 09:37
The Publish job on a91915a sat for 6 hours and was killed by GitHub's
hard limit. The nodefs test clones wasm-git from github.com over the
real network, and that transfer died at 68%:

  net 68% ( 247 kb, 476/699) / idx 40% (285/699)
  ERROR 12: could not read from remote repository

The ErrnoError errno 44 mocha reported is the follow-on ENOENT from
FS.chdir() into a clone directory that was never created. Mocha had
already printed "13 passing, 1 failing" — but never exited, because the
aborted clone leaves a live handle in the emscripten module and there is
no .mocharc and no --exit, so the event loop never drains.

--exit makes mocha terminate once the run is over, whatever handles third
party code left behind. Verified with a probe that leaks a listening
socket and throws: without --exit the process hangs until killed, with
--exit it exits immediately with code 1, preserving the failure.

This treats the symptom — the handle leak in the aborted clone, and the
network dependency in the nodefs test itself, are still there — but it
turns a runner occupied for six hours into an immediate visible failure.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@petersalomonsen
petersalomonsen merged commit 38eeacc into master Aug 22, 2026
6 checks passed
@petersalomonsen
petersalomonsen deleted the test-exit-on-hang branch August 22, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant