fix(test): tsgo changed-test typecheck test times out on loaded hosts (#163057)

The compiler interceptor adds a Node boot with the inherited NODE_OPTIONS
preload and spawns a second process for every compiler query, consuming the
transitive-consumer test budget on loaded hosts.

Use a /bin/sh interceptor to record arguments and exec the native compiler.
Each query stays one native process, matching the production resolver.
Keep the fixture-local TypeScript install and all assertions unchanged.
This commit is contained in:
Peter Steinberger 2026-10-02 03:24:23 -05:00 • committed by GitHub
parent e6b3a11851
commit 3ee9fb5c21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -582,19 +582,25 @@ it.runIf(process.platform !== "win32")(
);
}
fs.unlinkSync(path.join(root, "node_modules/.bin/tsgo"));
// Every boundary pass queries each graph config serially. Record and exec so
// each query stays one native process, as the production resolver launches it.
const compiler = write(
"node_modules/.bin/tsgo",
`#!/usr/bin/env node
const fs=require('node:fs'),path=require('node:path'),{spawnSync}=require('node:child_process');
const args=process.argv.slice(2);
fs.appendFileSync(path.join(process.cwd(),'compiler-events.jsonl'),JSON.stringify(args)+'\\n');
const result=spawnSync(${JSON.stringify(native)},args,{stdio:'inherit'});
if(process.env.TSGO_FIXTURE_STDERR==='1') process.stderr.write('unclassified compiler failure\\n');
process.exit(result.status??1);
`#!/bin/sh
IFS=$(printf '\\t')
printf '%s\\n' "$*" >> compiler-events.tsv
if [ "$TSGO_FIXTURE_STDERR" = 1 ]; then echo 'unclassified compiler failure' >&2; fi
exec ${JSON.stringify(native)} "$@"
`,
);
fs.chmodSync(compiler, 0o755);
overrideNativeFixtureExecutable(root, compiler);
const compilerEvents = () =>
fs
.readFileSync(path.join(root, "compiler-events.tsv"), "utf8")
.split("\n")
.filter(Boolean)
.map((line) => line.split("\t"));
const driver = path.join(root, "scripts/run-tsgo-core-test-shards.mts");
const preparedDriver = resolveRuntimeWorkerUrl(toolingMtsEntrypoints.tsgoCoreTestShards);
const env = preparedScriptWrapperEnv(
@ -623,7 +629,7 @@ process.exit(result.status??1);
stripe?: string,
expectedGraphListings = TSGO_CORE_GRAPHS.length,
) => {
write("compiler-events.jsonl", "");
write("compiler-events.tsv", "");
const result = await lifetime.track(
runNodeScript(
[
@ -638,12 +644,7 @@ process.exit(result.status??1);
{ cwd: root, signal, requireProcessTreeExit: true },
),
);
const calls = fs
.readFileSync(path.join(root, "compiler-events.jsonl"), "utf8")
.trim()
.split("\n")
.filter(Boolean)
.map((line) => JSON.parse(line) as string[]);
const calls = compilerEvents();
expect(calls.filter((args) => args.includes("--listFilesOnly"))).toHaveLength(
expectedGraphListings,
);
@ -694,7 +695,7 @@ if (process.argv[2] === "boundary") {
`,
);
const inspectExtension = async (mode: "plan" | "core-plan" | "boundary", serial = "") => {
write("compiler-events.jsonl", "");
write("compiler-events.tsv", "");
return await lifetime.track(
runNodeScript(
[
@ -716,11 +717,7 @@ if (process.argv[2] === "boundary") {
mode: "changed",
names: ["extensions", "extensions-test", "scripts", "test-root"],
});
const discovery = fs
.readFileSync(path.join(root, "compiler-events.jsonl"), "utf8")
.trim()
.split("\n")
.map((line) => JSON.parse(line) as string[]);
const discovery = compilerEvents();
expect(discovery).toHaveLength(serial ? 4 : 1);
expect(discovery.every((args) => args.includes(serial ? "--listFilesOnly" : "--api"))).toBe(
true,
@ -810,7 +807,7 @@ if (process.argv[2] === "boundary") {
write(leaf, "export const invalid: number = 'broken';\n");
const selectedGraphs = ["core-test-agents-other", "core-test-agents-tools"];
for (const mode of ["default", "evidence", "unknown"] as const) {
write("compiler-events.jsonl", "");
write("compiler-events.tsv", "");
const result = await lifetime.track(
runNodeScript(
[
@ -831,12 +828,7 @@ if (process.argv[2] === "boundary") {
);
expect(result.status, result.stderr).toBe(2);
expect(result.stdout).toContain("leaf.test.ts(1,14): error TS2322");
const invocations = fs
.readFileSync(path.join(root, "compiler-events.jsonl"), "utf8")
.trim()
.split("\n")
.filter(Boolean);
expect(invocations).toHaveLength(mode === "evidence" ? 2 : 1);
expect(compilerEvents()).toHaveLength(mode === "evidence" ? 2 : 1);
const receipts = result.stdout
.split("\n")
.filter((line) => line.startsWith("[ci-static:tsgo:"));