Skip to content

Commit 6f38b8d

Browse files
drixsonicclaude
andcommitted
fix(repo): run test workers without node's baseline compiler
A V8 garbage-collector crash in the baseline compiler (Sparkplug) of Node 24 can kill a test worker with SIGSEGV while no test has failed (upstream, nodejs/node#62393). It was seen in the tokens suite. Every package's vitest config now passes --no-sparkplug to its workers through execArgv, and `scripts:test` runs `node --no-sparkplug --test`, which hands the flag on to each test file's process. The browser config is left alone: its tests run in Chromium, not in Node. NODE_OPTIONS cannot carry the flag, because Node refuses V8 options outside a short allow list there, so pnpm's node-options setting was not an option. A tokens test asserts the flag reaches a worker, and a check in scripts reads every package's vitest config so a new package cannot leave it out. Remove the flag from the configs and from `scripts:test` once the pinned Node carries the V8 fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent acec2e8 commit 6f38b8d

9 files changed

Lines changed: 61 additions & 4 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"knip": "knip",
1919
"deps:lint": "syncpack lint",
2020
"deps:dedupe-check": "pnpm dedupe --check",
21-
"scripts:test": "mkdir -p scripts/coverage && node --test --experimental-test-coverage --test-coverage-include=scripts/*.mjs --test-coverage-exclude=scripts/*.test.mjs --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=scripts/coverage/lcov.info scripts/*.test.mjs",
21+
"scripts:test": "mkdir -p scripts/coverage && node --no-sparkplug --test --experimental-test-coverage --test-coverage-include=scripts/*.mjs --test-coverage-exclude=scripts/*.test.mjs --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=scripts/coverage/lcov.info scripts/*.test.mjs",
2222
"scripts:check": "node scripts/check-bundling-guard-coverage.mjs && node scripts/check-license-enumeration-provenance.mjs && node scripts/check-license-allowlist.mjs && node scripts/check-publishable-set.mjs && node scripts/check-license-parity.mjs && node scripts/check-adr-structure.mjs && node scripts/check-core-contract-drift.mjs && node scripts/check-eslint-plugin-style-properties-drift.mjs && node scripts/check-content-link-corpus.mjs && node scripts/check-readme-export-coverage.mjs && node scripts/check-no-orphaned-chunks.mjs && node scripts/check-ci-check-order.mjs && node scripts/check-ci-jobs-match-ci-check.mjs && node scripts/check-actions-pinned-shas.mjs && node scripts/check-dependabot-commit-scope.mjs && node scripts/check-pr-title-scopes.mjs && node scripts/check-zero-runtime-js.mjs",
2323
"ci:check": "node scripts/run-ci-check.mjs",
2424
"ci:check:fix": "pnpm run lint:fix && pnpm run ci:check",

‎packages/bridge/vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'
33
export default defineConfig({
44
test: {
55
environment: 'node',
6+
// A V8 garbage-collector crash in Node 24's baseline compiler (nodejs/node#62393) can kill a
7+
// test worker with SIGSEGV. Remove this once the pinned Node carries the fix.
8+
execArgv: ['--no-sparkplug'],
69
include: ['test/**/*.test.ts'],
710
},
811
})

‎packages/cli/vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'
33
export default defineConfig({
44
test: {
55
environment: 'node',
6+
// A V8 garbage-collector crash in Node 24's baseline compiler (nodejs/node#62393) can kill a
7+
// test worker with SIGSEGV. Remove this once the pinned Node carries the fix.
8+
execArgv: ['--no-sparkplug'],
69
include: ['test/**/*.test.ts'],
710
},
811
})

‎packages/core/vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { defaultExclude, defineConfig } from 'vitest/config'
33
export default defineConfig({
44
test: {
55
environment: 'node',
6+
// A V8 garbage-collector crash in Node 24's baseline compiler (nodejs/node#62393) can kill a
7+
// test worker with SIGSEGV. Remove this once the pinned Node carries the fix.
8+
execArgv: ['--no-sparkplug'],
69
include: ['test/**/*.test.ts'],
710
// test/browser/**/*.browser.test.ts is this same glob's problem too
811
// (it also ends in .test.ts): those fixtures need real browser globals

‎packages/eslint-plugin/vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'
33
export default defineConfig({
44
test: {
55
environment: 'node',
6+
// A V8 garbage-collector crash in Node 24's baseline compiler (nodejs/node#62393) can kill a
7+
// test worker with SIGSEGV. Remove this once the pinned Node carries the fix.
8+
execArgv: ['--no-sparkplug'],
69
include: ['test/**/*.test.ts'],
710
setupFiles: ['./test/setup/rule-tester.ts'],
811
testTimeout: 20_000,

‎packages/stylelint-config/vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'
33
export default defineConfig({
44
test: {
55
environment: 'node',
6+
// A V8 garbage-collector crash in Node 24's baseline compiler (nodejs/node#62393) can kill a
7+
// test worker with SIGSEGV. Remove this once the pinned Node carries the fix.
8+
execArgv: ['--no-sparkplug'],
69
include: ['test/**/*.test.ts'],
710
testTimeout: 20_000,
811
coverage: {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect, test } from 'vitest'
2+
3+
test('workers run without the baseline compiler, whose V8 crash kills a worker with SIGSEGV', () => {
4+
expect(process.execArgv).toContain('--no-sparkplug')
5+
})

‎packages/tokens/vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'
33
export default defineConfig({
44
test: {
55
environment: 'node',
6+
// A V8 garbage-collector crash in Node 24's baseline compiler (nodejs/node#62393) can kill a
7+
// test worker with SIGSEGV. Remove this once the pinned Node carries the fix.
8+
execArgv: ['--no-sparkplug'],
69
include: ['test/**/*.test.ts'],
710
coverage: {
811
// Measure and report only — no thresholds are configured, and none

‎scripts/prefix-lcov-source-paths.test.mjs‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ test('sync with the real repo: scripts:test writes its lcov report where sonar.j
218218
})
219219

220220
test('scripts:test measures the scripts, not their tests: its lcov names run-ci-check.mjs and no *.test.mjs', () => {
221-
// Runs the shipped command's own flags over one small test file, with the report redirected to
222-
// a scratch directory, so this does not start the whole suite from inside itself.
221+
// Runs the shipped command's own flags over one small test file (it imports run-ci-check.mjs and
222+
// starts no processes), with the report redirected to a scratch directory, so this does not
223+
// start the whole suite from inside itself.
223224
// Node does not create the report's directory, so the command makes it first; drop that part.
224225
const words = scriptsTestCommand().split(' && ').at(-1).split(/\s+/)
225226
assert.equal(words[0], 'node')
@@ -230,7 +231,7 @@ test('scripts:test measures the scripts, not their tests: its lcov names run-ci-
230231
.slice(1)
231232
.map((word) =>
232233
word === 'scripts/*.test.mjs'
233-
? 'scripts/run-ci-check.test.mjs'
234+
? 'scripts/check-ci-jobs-match-ci-check.test.mjs'
234235
: word.replace(/=\S*lcov\.info$/, () => `=${lcovPath}`),
235236
)
236237
// Inside a `node --test` run these two would make the nested run behave as one of its tests.
@@ -288,6 +289,39 @@ test('the rewrite leaves Node’s lcov SF: paths repo-root-relative, for every r
288289
}
289290
})
290291

292+
/**
293+
* True when a vitest config sets `execArgv` to a list holding `--no-sparkplug` on a line that is
294+
* not a comment.
295+
*/
296+
function runsWorkersWithoutSparkplug(configText) {
297+
const code = configText
298+
.split('\n')
299+
.filter((line) => !line.trimStart().startsWith('//'))
300+
.join('\n')
301+
return /\bexecArgv:\s*\[[^\]]*'--no-sparkplug'[^\]]*\]/.test(code)
302+
}
303+
304+
test('runsWorkersWithoutSparkplug ignores a commented-out execArgv', () => {
305+
assert.equal(runsWorkersWithoutSparkplug("// execArgv: ['--no-sparkplug'],"), false)
306+
assert.equal(runsWorkersWithoutSparkplug("test: {\n execArgv: ['--no-sparkplug'],\n}"), true)
307+
})
308+
309+
test('scripts:test runs node without the baseline compiler, and node --test hands that on to its test files', () => {
310+
assert.match(scriptsTestCommand(), /\bnode --no-sparkplug --test\b/)
311+
})
312+
313+
test('sync with the real repo: every package vitest config runs its workers without the baseline compiler', () => {
314+
// A V8 crash in Node 24's baseline compiler kills a test worker with SIGSEGV, so each node
315+
// config sets the flag. Reading the files means a new package cannot drop it unnoticed.
316+
const packagesDir = path.join(ROOT, 'packages')
317+
const missing = readdirSync(packagesDir, { withFileTypes: true })
318+
.filter((entry) => entry.isDirectory())
319+
.map((entry) => `packages/${entry.name}/vitest.config.ts`)
320+
.filter((file) => existsSync(path.join(ROOT, file)))
321+
.filter((file) => !runsWorkersWithoutSparkplug(readFileSync(path.join(ROOT, file), 'utf8')))
322+
assert.deepEqual(missing, [])
323+
})
324+
291325
test('sync with the real repo: packages whose test run writes coverage match sonar.javascript.lcov.reportPaths', () => {
292326
// A package's `test` writes a coverage report when its vitest config turns coverage on, so
293327
// that switch is what decides which lcov files exist for the scan to read.

0 commit comments

Comments
 (0)