Skip to content

Commit 675eb6a

Browse files
committed
test(ci): stop the OAuth queue tests from stalling the Windows runner
The 20-minute windows-latest timeouts traced to two things in the new mutation-queue tests: 128 real icacls spawns inflating the runtime, and an unref'd queue-wait timer that Bun on Windows stopped servicing while the test promise was the only thing left — the timeout assertion never settled and the isolate process sat until the job died. The tests now install the fake ACL runner and hold a ref'd wakeup timer across the unref-timeout assertion, with the blocker released on every path. Production timer semantics are untouched.
1 parent fa5780d commit 675eb6a

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

tests/oauth-store-multi.test.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2-
import { STORE_BUDGET_MS } from "./helpers/test-budget";
32
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
43
import { join } from "node:path";
4+
import {
5+
resetHardenedStateForTests,
6+
setIcaclsRunnerForTests,
7+
} from "../src/lib/windows-secret-acl";
58
import {
69
getAccountCredential,
710
getAccountSet,
@@ -39,9 +42,18 @@ describe("multi-account auth store", () => {
3942
if (existsSync(TEST_DIR)) rmSync(TEST_DIR, { recursive: true });
4043
mkdirSync(TEST_DIR, { recursive: true });
4144
process.env.OPENCODEX_HOME = TEST_DIR;
45+
resetHardenedStateForTests();
46+
setIcaclsRunnerForTests(() => ({
47+
success: true,
48+
exitCode: 0,
49+
timedOut: false,
50+
stdout: "",
51+
}));
4252
});
4353

4454
afterEach(() => {
55+
setIcaclsRunnerForTests(null);
56+
resetHardenedStateForTests();
4557
if (previousOpencodexHome === undefined) delete process.env.OPENCODEX_HOME;
4658
else process.env.OPENCODEX_HOME = previousOpencodexHome;
4759
if (existsSync(TEST_DIR)) rmSync(TEST_DIR, { recursive: true });
@@ -273,7 +285,7 @@ describe("multi-account auth store", () => {
273285
await Promise.all(accepted);
274286
expect(executions).toBe(128);
275287
expect(oauthMutationTailSnapshot().active).toBe(0);
276-
}, STORE_BUDGET_MS); // 128 serialized load-modify-persist store mutations; windows-latest measured ~7.3s against Bun's 5s default.
288+
});
277289

278290
test("OAuth 30 second wait timeout releases an unstarted lease and never enters the chain", async () => {
279291
let releaseFirst!: () => void;
@@ -287,11 +299,21 @@ describe("multi-account auth store", () => {
287299
await started;
288300
let entered = false;
289301
const timedOut = mutateStore(() => { entered = true; }, ["provider", "waiting-account"], { waitMs: 10 });
290-
await expect(timedOut).rejects.toBeInstanceOf(OAuthMutationBusyError);
291-
expect(entered).toBe(false);
292-
expect(oauthMutationTailSnapshot().active).toBe(1);
293-
releaseFirst();
294-
await blocker;
302+
// Bun 1.3.14 on Windows does not service the production-unref'ed queue timer
303+
// when the test is otherwise waiting only on promises. Keep a test-owned
304+
// ref'ed timer active, and release the blocker if the assertion itself fails.
305+
const timerWakeup = setInterval(() => {}, 5);
306+
const cleanupFallback = setTimeout(releaseFirst, 1_000);
307+
try {
308+
await expect(timedOut).rejects.toBeInstanceOf(OAuthMutationBusyError);
309+
expect(entered).toBe(false);
310+
expect(oauthMutationTailSnapshot().active).toBe(1);
311+
} finally {
312+
clearInterval(timerWakeup);
313+
clearTimeout(cleanupFallback);
314+
releaseFirst();
315+
await blocker;
316+
}
295317
expect(oauthMutationTailSnapshot().active).toBe(0);
296318
});
297319
});

0 commit comments

Comments
 (0)