diff --git a/bun.lock b/bun.lock index 904952a..213ca6c 100644 --- a/bun.lock +++ b/bun.lock @@ -55,7 +55,7 @@ }, "packages/cli": { "name": "gitdog", - "version": "0.5.1", + "version": "0.6.0", "bin": { "gitdog": "dist/cli.js", }, @@ -464,7 +464,7 @@ "cookie-es": ["cookie-es@3.1.1", "", {}, "sha512-UaXxwISYJPTr9hwQxMFYZ7kNhSXboMXP+Z3TRX6f1/NyaGPfuNUZOWP1pUEb75B2HjfklIYLVRfWiFZJyC6Npg=="], - "cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="], + "cross-spawn": ["cross-spawn@7.1.0", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-/PHUIV1x/hZLpJN8KmyV2aYkT8pll4RjQ59TmhwkL/9B4HdOtlBQ2pos6iB2cfVRzpGHk3HXlRa8sdVYrPjIYw=="], "cssesc": ["cssesc@3.0.0", "", { "bin": { "cssesc": "bin/cssesc" } }, "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg=="], diff --git a/test/convex/repoIndexing/treeSnapshotContinuation.test.ts b/test/convex/repoIndexing/treeSnapshotContinuation.test.ts index 57fe78a..68c219c 100644 --- a/test/convex/repoIndexing/treeSnapshotContinuation.test.ts +++ b/test/convex/repoIndexing/treeSnapshotContinuation.test.ts @@ -94,6 +94,24 @@ async function yieldToRuntime(): Promise { }); } +/** + * Lets the backend run until `done`, bounded by real time rather than by a + * number of steps: a cold first import of the backend modules can take longer + * than any fixed count of fake-time steps. Fake time moves at most + * `maxFakeMs`, so jobs scheduled further out never run on their own. A test + * that uses it needs a timeout above the ten-second deadline. + */ +async function runUntil(done: () => boolean, maxFakeMs: number): Promise { + const deadline = process.hrtime.bigint() + 10_000_000_000n; + let fakeMs = 0; + while (!done() && process.hrtime.bigint() < deadline) { + const step = fakeMs < maxFakeMs ? 1 : 0; + await advanceTestTime(step); + fakeMs += step; + await yieldToRuntime(); + } +} + async function advanceTestTime(milliseconds: number): Promise { if (timerApi.advanceTimersByTimeAsync) { await timerApi.advanceTimersByTimeAsync(milliseconds); @@ -1795,12 +1813,7 @@ describe("repository tree snapshot continuations", () => { // Let the headerless secondary limit reach the durable retry path. Keeping // fake time below its one-minute fallback prevents convex-test from // auto-running the job that this assertion intentionally invokes manually. - for (let attempt = 0; attempt < 20; attempt++) { - await advanceTestTime(1); - if (blobCalls.get("rate-8") === 1) { - break; - } - } + await runUntil(() => blobCalls.get("rate-8") === 1, 20); expect(blobCalls.get("rate-8")).toBe(1); await expect(initialIndex).resolves.toMatchObject({ success: true, @@ -1832,12 +1845,7 @@ describe("repository tree snapshot continuations", () => { rateLimitResume: true, rateLimitRetryToken: deferred!.indexRateLimitRetryToken!, }); - for (let attempt = 0; attempt < 20; attempt++) { - await advanceTestTime(0); - if (successfulRetryPending) { - break; - } - } + await runUntil(() => successfulRetryPending, 0); expect(successfulRetryPending).toBe(true); await advanceTestTime(1); const retryResult = await retry; @@ -1852,7 +1860,7 @@ describe("repository tree snapshot continuations", () => { expect(fileMaps).toHaveLength(10); expect(blobCalls.get("rate-8")).toBe(2); expect(blobCalls.get("rate-9")).toBe(1); - }); + }, 30_000); it("refetches after a late blob upload loses the publication fence", async () => { const t = convexTest(schema, modules);