Skip to content

Commit a9cbaf8

Browse files
lacionclaude
andcommitted
ci: dodge the Node 22 runner-IPC bug with a filewise lane; fix a live ESM require(); give slow CI tests real headroom
Three fixes for what the Node 22 lanes keep hitting: 1. nodejs/node#64061 — the 22.x test runner's parent<->child IPC corrupts under CI load ("Unable to deserialize cloned data", #processRawBuffer), deterministically killing tests/cli.test.mjs on 22.13.0 and latest-22 while Node 24 (which ships the #64706 fix) is green. The 22.x backport is unreleased as of 2026-08, so the Node 22 CI lanes (matrix 22.13.0, bundle, macos) now run scripts/run-tests-filewise.mjs: every test file executed DIRECTLY, one process per file — node:test runs in-process, no runner IPC exists to corrupt, and the loop preserves per-file process isolation. Discovery is recursive (tests/helpers/ too — verified 122/122 files, 1137/1137 tests, matching `npm test` exactly). Node 24 lanes and publish.yml keep the standard runner. REVERT the lane wiring when a 22.x release carries the backport. 2. tests/smoke-project-isolation.test.mjs called require('node:http') inside a SIGUSR1 handler in live ESM — a guaranteed ReferenceError on a late teardown path that slow CI delays past test end, surfacing as async-activity-after-test and failing the file. createServer is a top-level import now. 3. --test-timeout 120s -> 300s: election.test.mjs legitimately exceeded 120s on a loaded 2-core runner. 300s still names a hung test loudly instead of wedging the job to the 20-minute kill. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 898e8d5 commit a9cbaf8

4 files changed

Lines changed: 102 additions & 6 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ jobs:
2828
node-version: ${{ matrix.node-version }}
2929
cache: npm
3030
- run: npm ci --ignore-scripts
31-
- run: npm test
31+
# Node 22's test runner corrupts its parent<->child IPC under CI load
32+
# ("Unable to deserialize cloned data" — nodejs/node#64061; fixed by
33+
# #64706, which current Node 24 ships but whose 22.x backport is
34+
# unreleased as of 2026-08). The filewise runner executes each test file
35+
# in-process (no runner IPC) with the same per-file process isolation.
36+
# REVERT to plain `npm test` here when a 22.x release carries the fix.
37+
- if: matrix.node-version != '24'
38+
run: npm run test:filewise
39+
env:
40+
FLEETDECK_TEST_WAIT_SCALE: 3
41+
- if: matrix.node-version == '24'
42+
run: npm test
3243
# Shared-runner lanes are slow and noisy in exactly the way the macOS
3344
# advisory lane is — every wait routes through the WAIT_SCALE knob
3445
# (tests/helpers/wait.mjs), so give the Linux lanes the same headroom
@@ -51,7 +62,9 @@ jobs:
5162
- run: npm run bundle
5263
- name: Fail if committed bundle is stale
5364
run: git diff --exit-code scripts/fleetd/fleetd.bundle.mjs
54-
- run: npm run test:bundle
65+
# filewise for the same reason as the Node 22 test lane above
66+
# (nodejs/node#64061) — this job runs on Node 22.
67+
- run: npm run test:bundle:filewise
5568
env:
5669
FLEETDECK_TEST_WAIT_SCALE: 3
5770

@@ -91,7 +104,9 @@ jobs:
91104
node-version: '22'
92105
cache: npm
93106
- run: npm ci --ignore-scripts
94-
- run: npm test
107+
# filewise for the same reason as the Node 22 test lane above
108+
# (nodejs/node#64061) — this job runs on Node 22.
109+
- run: npm run test:filewise
95110
env:
96111
FLEETDECK_TEST_WAIT_SCALE: 3
97112

‎package.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
],
3535
"scripts": {
3636
"start": "node --no-warnings=ExperimentalWarning scripts/fleetd/fleetd.mjs",
37-
"test": "node --test --test-concurrency=1 --test-timeout=120000",
38-
"test:bundle": "FLEETDECK_TEST_DAEMON_SCRIPT=$PWD/scripts/fleetd/fleetd.bundle.mjs node --test --test-concurrency=1 --test-timeout=120000",
37+
"test": "node --test --test-concurrency=1 --test-timeout=300000",
38+
"test:bundle": "FLEETDECK_TEST_DAEMON_SCRIPT=$PWD/scripts/fleetd/fleetd.bundle.mjs node --test --test-concurrency=1 --test-timeout=300000",
39+
"test:filewise": "node scripts/run-tests-filewise.mjs",
40+
"test:bundle:filewise": "FLEETDECK_TEST_DAEMON_SCRIPT=$PWD/scripts/fleetd/fleetd.bundle.mjs node scripts/run-tests-filewise.mjs",
3941
"bundle": "esbuild scripts/fleetd/fleetd.mjs --bundle --platform=node --format=esm --outfile=scripts/fleetd/fleetd.bundle.mjs --external:bufferutil --external:utf-8-validate --banner:js=\"// GENERATED by 'npm run bundle' — do not edit. Source: scripts/fleetd/*.mjs\nimport { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);\"",
4042
"build:board": "cd board && npm install && npm run build",
4143
"smoke": "bash demo/run-smoke.sh"

‎scripts/run-tests-filewise.mjs‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// run-tests-filewise.mjs — run every test file DIRECTLY, one process per file,
2+
// with no `node --test` runner in front.
3+
//
4+
// WHY THIS EXISTS (remove when it stops being true): the Node 22.x test
5+
// runner's parent<->child IPC has a deserialization bug — under CI load the
6+
// parent throws "Unable to deserialize cloned data due to invalid or
7+
// unsupported version" out of #processRawBuffer and fails whole test files
8+
// that pass everywhere else (nodejs/node#64061; fixed by nodejs/node#64706,
9+
// which current Node 24 already ships — our Node 24 lane is green on the
10+
// plain runner — but whose 22.x backport has not been released as of
11+
// 2026-08). Running each file as a plain script executes node:test
12+
// IN-PROCESS: no runner child, no IPC, nothing to mis-deserialize, while the
13+
// one-process-per-file loop below preserves exactly the isolation the runner
14+
// gives us (fresh process, fresh env, per-file exit code).
15+
//
16+
// REVERT PATH: when a Node 22.x release carries the #64706 backport, bump the
17+
// CI floor to it and point the Node 22 lanes back at plain `npm test`.
18+
//
19+
// Semantics kept identical to `npm test`:
20+
// - files run sequentially (the suite's contract is --test-concurrency=1)
21+
// - per-test {timeout} options still apply (node:test honors them in-process)
22+
// - a wedged FILE is killed at the same 300s ceiling npm test uses per test,
23+
// scaled to the file (600s), and named loudly instead of hanging the job
24+
// - FLEETDECK_TEST_DAEMON_SCRIPT et al. pass through the environment
25+
26+
import { spawnSync } from 'node:child_process';
27+
import { readdirSync } from 'node:fs';
28+
import path from 'node:path';
29+
import { fileURLToPath } from 'node:url';
30+
31+
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
32+
const TESTS_DIR = path.join(REPO_ROOT, 'tests');
33+
34+
// Recursive: `node --test` discovers test files in subdirectories too
35+
// (tests/helpers/gitrepo.test.mjs), and a filewise run that silently drops a
36+
// file is exactly the vacuous-pass hazard this suite guards against — the
37+
// summary line prints the file count so a discovery regression is visible,
38+
// and the per-file `# tests` totals let CI logs be diffed against `npm test`.
39+
const files = readdirSync(TESTS_DIR, { recursive: true })
40+
.filter(name => String(name).endsWith('.test.mjs'))
41+
.sort()
42+
.map(name => path.join('tests', String(name)));
43+
44+
if (files.length === 0) {
45+
console.error('run-tests-filewise: no tests/*.test.mjs files found');
46+
process.exit(1);
47+
}
48+
49+
const failures = [];
50+
const started = Date.now();
51+
for (const [i, file] of files.entries()) {
52+
console.log(`\n# [${i + 1}/${files.length}] ${file}`);
53+
const result = spawnSync(process.execPath, [file], {
54+
cwd: REPO_ROOT,
55+
stdio: 'inherit',
56+
env: process.env,
57+
timeout: 600_000,
58+
});
59+
if (result.status !== 0) {
60+
const why = result.signal
61+
? `killed by ${result.signal}${result.error?.code === 'ETIMEDOUT' ? ' (600s file watchdog)' : ''}`
62+
: `exit ${result.status}`;
63+
failures.push(`${file} — ${why}`);
64+
console.error(`# FAIL ${file} (${why})`);
65+
}
66+
}
67+
68+
const secs = Math.round((Date.now() - started) / 1000);
69+
console.log(`\n# filewise summary: ${files.length - failures.length}/${files.length} files passed in ${secs}s`);
70+
if (failures.length) {
71+
console.error('# failing files:');
72+
for (const f of failures) console.error(`# ${f}`);
73+
process.exit(1);
74+
}

‎tests/smoke-project-isolation.test.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import { test } from 'node:test';
1717
import assert from 'node:assert/strict';
1818
import { execFileSync, spawnSync } from 'node:child_process';
19+
import { createServer } from 'node:http';
1920
import {
2021
chmodSync,
2122
cpSync,
@@ -61,8 +62,12 @@ function seedDaemonProofs(t, sandbox, binDir, smokePort) {
6162
// The first SIGUSR1 swaps this process for a tiny health server answering
6263
// with the recorded pid; the smoke's SIGTERM then closes it and the process
6364
// exits, satisfying the liveness poll.
65+
// NOTE: this handler is live ESM — `require()` here threw ReferenceError,
66+
// and because the signal can arrive after the registering test has ended
67+
// (slow CI), the throw surfaced as async-activity-after-test in whichever
68+
// test happened to be current, failing the whole file. createServer is a
69+
// top-level import now.
6470
process.once('SIGUSR1', () => {
65-
const { createServer } = require('node:http');
6671
const server = createServer((req, res) => {
6772
if (req.url === '/health') {
6873
res.writeHead(200, { 'content-type': 'application/json' });

0 commit comments

Comments
 (0)