Skip to content

Commit 57c6f76

Browse files
authored
fix(test): prevent CLI process loader hangs (#117830)
1 parent aff240d commit 57c6f76

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎src/cli/help-exit.process.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ type CliProcessFailure = Error & {
215215
stdout?: string;
216216
};
217217
describe("CLI help process exit", () => {
218+
it("disables esbuild worker IPC for source CLI children", () => {
219+
expect(process.env.ESBUILD_WORKER_THREADS).toBe("0");
220+
});
221+
218222
it("exits promptly after root --help", async () => {
219223
// Keep this precomputed-help case off plugin discovery; plugin-sensitive root help is covered
220224
// separately, so the shared child timeout remains a deadlock guard rather than a startup SLO.

‎test/vitest-scoped-config.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,9 @@ describe("scoped vitest configs", () => {
623623
);
624624
expect(requireTestConfig(defaultCliProcessConfig).include).toEqual(cliProcessTestFiles);
625625
expect(requireTestConfig(defaultCliProcessConfig).fileParallelism).toBe(false);
626+
expect(requireTestConfig(defaultCliProcessConfig).env).toMatchObject({
627+
ESBUILD_WORKER_THREADS: "0",
628+
});
626629
});
627630

628631
it("keeps native SQLite runtime config tests in forked workers", () => {

‎test/vitest/vitest.cli-process.config.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { cliProcessTestFiles } from "./vitest.cli-process-paths.mjs";
44
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
55

66
export function createCliProcessVitestConfig(env?: Record<string, string | undefined>) {
7-
return createScopedVitestConfig(cliProcessTestFiles, {
7+
const config = createScopedVitestConfig(cliProcessTestFiles, {
88
env,
99
fileParallelism: false,
1010
isolate: true,
@@ -13,6 +13,17 @@ export function createCliProcessVitestConfig(env?: Record<string, string | undef
1313
pool: "forks",
1414
useNonIsolatedRunner: false,
1515
});
16+
return {
17+
...config,
18+
test: {
19+
...config.test,
20+
env: {
21+
...config.test?.env,
22+
// Avoid TSX's unbounded wait on esbuild's synchronous worker IPC in source-child tests.
23+
ESBUILD_WORKER_THREADS: "0",
24+
},
25+
},
26+
};
1627
}
1728

1829
export default createCliProcessVitestConfig();

0 commit comments

Comments
 (0)