From afee630120154adec70e91846544271a218f3555 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Wed, 18 Nov 2026 15:59:47 -0800 Subject: [PATCH] Respect dispatch-hint coalescing in the handover test The first replacement hint can arrive before the test samples its wake counter. A skipped dispatch inside the existing hint cooldown then emits no new notification, so waiting for a second hint without another dispatch fails even though the handover works. Make the cooldown observable, wait for the initial hint, and retry the old server's skipped dispatch within the existing wait. Keep proving that the old server refuses the run and the replacement claims it exactly once. Verification: the controlled cooldown case reproduced CI's expected-1-to- be-greater-than-1 failure before the change. All 19 handover tests pass after the change. The original suite also passed in local isolation. Co-Authored-By: Paperclip --- server/src/__tests__/run-start-handover.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/__tests__/run-start-handover.test.ts b/server/src/__tests__/run-start-handover.test.ts index 56b79603a12..adf58022a08 100644 --- a/server/src/__tests__/run-start-handover.test.ts +++ b/server/src/__tests__/run-start-handover.test.ts @@ -110,7 +110,7 @@ suite("run start hand-over between an old and a new server during a deploy overl it("the old server stops starting runs once the new one starts them, and the new one starts the queued run", async () => { // The old server booted alone long ago: it recorded its own start and holds no hand-over. - const old = await bootServer("old"); + const old = await bootServer("old", { timing: { skipHintMinMs: 500 } }); await old.handover.begin(); expect(old.handover.isHandingOver()).toBe(false); const before = await queueRun(); @@ -126,12 +126,16 @@ suite("run start hand-over between an old and a new server during a deploy overl expect(next.handover.isHandingOver()).toBe(true); expect(await marker(next)).toMatchObject({ live: true }); await vi.waitFor(() => expect(old.handover.isActive()).toBe(true), { timeout: 10_000 }); + await vi.waitFor(() => expect(next.dispatchHints).toBeGreaterThan(0), { timeout: 10_000 }); const handedOver = await queueRun(); const hintsBefore = next.dispatchHints; expect(await dispatch(old, handedOver)).toBe(false); // The skipped start wakes the new server's queued-run dispatch instead of waiting for a sweep. - await vi.waitFor(() => expect(next.dispatchHints).toBeGreaterThan(hintsBefore), { timeout: 10_000 }); + await vi.waitFor(async () => { + expect(await dispatch(old, handedOver)).toBe(false); + expect(next.dispatchHints).toBeGreaterThan(hintsBefore); + }, { timeout: 10_000 }); expect(await dispatch(next, handedOver)).toBe(true); expect(claims.filter(claim => claim.runId === handedOver)).toEqual([{ server: "new", runId: handedOver }]);