Skip to content

Commit 0bccc8a

Browse files
committed
test(responses-state): probe a genuinely dead pid for the symlinked-sweep test
The symlinked-directory sweep test drives the real load path, whose stale-temp sweep checks liveness with kill(pid, 0). The hardcoded dead pid (4242/4243) collided with a live process on the macos CI runner, so the temp survived and the assertion flaked red while the same commit passed locally and on ubuntu. Probe upward for a pid that returns ESRCH instead; the injected-liveness tests are untouched.
1 parent a8e0fe0 commit 0bccc8a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

tests/responses-state.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,22 @@ describe("Responses previous_response_id state", () => {
14571457
writeFileSync(realSnapshot, JSON.stringify({ version: 2, states: [] }));
14581458
symlinkSync(realSnapshot, join(home, "responses-state.json"));
14591459

1460-
const deadPid = process.pid === 4242 ? 4243 : 4242;
1460+
// This test drives the REAL load path, whose sweep probes live pids with kill(pid, 0).
1461+
// A hardcoded "dead" pid can collide with a live process on a shared CI runner, so
1462+
// probe for a genuinely dead one instead (ESRCH). EPERM means alive-but-not-ours.
1463+
let deadPid = -1;
1464+
for (let candidate = 4242; candidate < 5242; candidate++) {
1465+
if (candidate === process.pid) continue;
1466+
try {
1467+
process.kill(candidate, 0);
1468+
} catch (error) {
1469+
if ((error as NodeJS.ErrnoException).code === "ESRCH") {
1470+
deadPid = candidate;
1471+
break;
1472+
}
1473+
}
1474+
}
1475+
expect(deadPid).toBeGreaterThan(0);
14611476
const stranded = join(realDir, `responses-state.json.ocx.${deadPid}.1.tmp`);
14621477
writeFileSync(stranded, "private state");
14631478
const old = new Date(Date.now() - 60 * 60 * 1_000);

0 commit comments

Comments
 (0)