From 6b9874f9b8045f7d1c8463eb2547fe5e056910fb Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 26 Oct 2026 21:10:06 -0500 Subject: [PATCH] Carry login cleanup fixture settlement through the whole stack Backport the existing deadline-aware settlement helper so earlier PRs no longer leave fake-time cleanup work paused beyond their initial clock jump. All sixteen login lifecycle cases pass. Co-Authored-By: Paperclip --- doc/idle-login-cleanup.md | 17 +++++++++++++++++ server/src/__tests__/login-cleanup-work.test.ts | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/idle-login-cleanup.md b/doc/idle-login-cleanup.md index 813cf34eb85..5bc3ebf62ac 100644 --- a/doc/idle-login-cleanup.md +++ b/doc/idle-login-cleanup.md @@ -95,3 +95,20 @@ cover the surrounding login contracts. The fake-clock database fixture warms its connections and disables pool idle/lifetime expiry so time jumps test the worker rather than racing socket connection timers. Database suspension and reconnect behavior require separate qualification. + +## CI fixture settlement across the migration stack + +The setup-token consume fixture can finish its initial fake-clock jump while +cleanup is still performing database work. A write during that pass can request +another generation whose coalesced deadline lies beyond the jump. Waiting for +zero tracked work without advancing to that registered deadline then times out, +even though cleanup has a valid wake and can finish. + +The existing fixture repair from `59f8c8b3e5` is now carried at the earliest stack +branch so every intermediate PR receives it. The helper advances to registered +deadlines only while work remains tracked, preserving its existing five-second +observation limit and all production behavior. All 16 login-cleanup cases passed +on this branch against a dedicated PostgreSQL database; the prior later-branch +verification and failed CI history remain documented in the GitHub review-check +migration audit. No runtime change or weakened quiet assertion is included. +Evidence: `/tmp/sleep-login-settlement-owning-tests.log` and its zero status file. diff --git a/server/src/__tests__/login-cleanup-work.test.ts b/server/src/__tests__/login-cleanup-work.test.ts index c21d04c97d3..081fc6eece6 100644 --- a/server/src/__tests__/login-cleanup-work.test.ts +++ b/server/src/__tests__/login-cleanup-work.test.ts @@ -116,7 +116,13 @@ describe.skipIf(!support.supported)("durable login cleanup", () => { }); async function settle(ms = 30_000) { await vi.advanceTimersByTimeAsync(ms); - await vi.waitFor(() => expect(idleWorkSnapshot().active).toBe(0), { timeout: 5000 }); + await vi.waitFor(async () => { + if (idleWorkSnapshot().active > 0) { + const deadlines = coordinators.flatMap(c => c.nextWakeAt() === null ? [] : [c.nextWakeAt()!]); + if (deadlines.length) await vi.advanceTimersByTimeAsync(Math.max(0, Math.min(...deadlines) - Date.now())); + } + expect(idleWorkSnapshot().active).toBe(0); + }, { timeout: 5000 }); await vi.advanceTimersByTimeAsync(1); await vi.waitFor(() => expect(idleWorkSnapshot().active).toBe(0), { timeout: 5000 }); expect(errors).toEqual([]);