Skip to content

Commit f25b196

Browse files
committed
fix(repo): run tests without Sparkplug, whose Node 24 GC bug segfaults them
Node 24's V8 pushes a stale register in Sparkplug's BaselineOutOfLinePrologue, which the GC reads as a pointer and segfaults on (nodejs/node#62393; the backport is open in nodejs/node#65753). It killed the Vitest process mid-run with exit 139, and can kill the Wrangler child that bundles connect for core's tests, which Wrangler's launcher reports as success.
1 parent d0b0ddc commit f25b196

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎apps/core/test/build-connect.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "../../connect/build.ts";
1515

1616
const connect = path.join(import.meta.dirname, "../../connect");
17-
const wrangler = path.join(connect, "node_modules/.bin/wrangler");
17+
const wrangler = path.join(connect, "node_modules/wrangler/bin/wrangler.js");
1818

1919
/** Where core's global setup writes the bundle for its tests. */
2020
export const connectBundle = path.join(
@@ -27,10 +27,15 @@ export const bundleConnect = async (): Promise<string> => {
2727
await buildConnectors(connectorEntries(), connectorsFile);
2828
const out = mkdtempSync(path.join(tmpdir(), "grasp-os-connect-"));
2929
try {
30-
// Its output is only shown if bundling fails, in the error.
31-
execFileSync(wrangler, ["deploy", "--dry-run", "--outdir", out], {
32-
cwd: connect,
33-
});
30+
// Its output is only shown if bundling fails, in the error. Wrangler's
31+
// launcher passes Node's flags on to the CLI it spawns, and reports the
32+
// CLI dying of a signal as success: without Sparkplug, Node 24's GC
33+
// segfault (vite.config.ts) can't kill it and leave no bundle behind.
34+
execFileSync(
35+
process.execPath,
36+
["--no-sparkplug", wrangler, "deploy", "--dry-run", "--outdir", out],
37+
{ cwd: connect }
38+
);
3439
return readFileSync(path.join(out, "index.js"), "utf-8");
3540
} finally {
3641
rmSync(out, { recursive: true, force: true });

‎vite.config.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { setFlagsFromString } from "node:v8";
2+
13
import ultracite from "ultracite/oxfmt";
24
import antiSlop from "ultracite/oxlint/anti-slop";
35
import core from "ultracite/oxlint/core";
@@ -7,6 +9,15 @@ import tanstack from "ultracite/oxlint/tanstack";
79
import vitest from "ultracite/oxlint/vitest";
810
import { defineConfig } from "vite-plus";
911

12+
// Node 24's V8 has a Sparkplug bug that segfaults the Vitest process
13+
// mid-run (exit 139) in GC: BaselineOutOfLinePrologue pushes a stale
14+
// register that the GC reads as a pointer
15+
// (https://github.com/nodejs/node/issues/62393). `vp test` starts Vitest
16+
// itself and NODE_OPTIONS rejects V8 flags, so switch the baseline tier off
17+
// here, where Vitest loads its config. Drop this once the Node release in
18+
// devEngines carries the backport (https://github.com/nodejs/node/pull/65753).
19+
setFlagsFromString("--no-sparkplug");
20+
1021
const generated = [
1122
"**/routeTree.gen.ts",
1223
"**/worker-configuration.d.ts",

0 commit comments

Comments
 (0)