Skip to content

Commit f7f47b2

Browse files
committed
fix(test): preserve signal exits after report finalization
1 parent 952d7f3 commit f7f47b2

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎scripts/test-extension-batch.mts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Runs grouped Vitest plans for one or more bundled plugins.
44
import path from "node:path";
55
import pMap from "p-map";
6+
import { waitForever } from "../src/cli/wait.ts";
67
import { collectVitestExcludePatterns } from "../test/vitest/vitest.pattern-file.ts";
78
import { resolveVitestFsModuleCacheRoot } from "../test/vitest/vitest.performance-config.ts";
89
import {
@@ -368,10 +369,9 @@ export async function runExtensionBatchPlan(
368369
process.off("SIGINT", onSignal);
369370
if (termination.signal) {
370371
process.kill(process.pid, termination.signal);
371-
// Give the re-raised signal a turn before a CLI caller exits with the numeric result.
372-
await new Promise<void>((resolve) => {
373-
setImmediate(resolve);
374-
});
372+
// Keep the loop alive for dependency signal handlers to finish cleanup
373+
// and re-raise; a numeric return can win the race with signal delivery.
374+
await waitForever();
375375
}
376376
}
377377
}

‎scripts/test-projects.mts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { SpawnOptions } from "node:child_process";
44
import fs from "node:fs";
55
import { performance } from "node:perf_hooks";
66
import pMap from "p-map";
7+
import { waitForever } from "../src/cli/wait.ts";
78
import { formatMs } from "./lib/check-timing-summary.mts";
89
import {
910
prepareE2eVitestRuntime,
@@ -471,10 +472,9 @@ async function main() {
471472
process.off("SIGINT", onSignal);
472473
if (termination.signal) {
473474
process.kill(process.pid, termination.signal);
474-
// Give the re-raised signal a turn before a CLI caller exits with the numeric result.
475-
await new Promise<void>((resolve) => {
476-
setImmediate(resolve);
477-
});
475+
// Keep the loop alive for dependency signal handlers to finish cleanup
476+
// and re-raise; a numeric return can win the race with signal delivery.
477+
await waitForever();
478478
}
479479
}
480480
}

0 commit comments

Comments
 (0)