From 68e7f7f927c18590b7b667ad2eb29ee21660fe80 Mon Sep 17 00:00:00 2001 From: Aaron Rono Date: Fri, 6 Nov 2026 08:11:43 +0300 Subject: [PATCH] test: wait on the clock in sync service tests until() gave up silently after 20,000 event-loop turns. On the Windows release runner sign-in and sync runs had not finished by then, so tests went on early: the pairing test chose a repository before sign-in ended and was reset to choosingRepository, and others saw sync still running. Wait up to 10 seconds of wall-clock time and throw when that passes, so a slow wait fails where it happens. --- electron/sync-service.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/electron/sync-service.test.ts b/electron/sync-service.test.ts index 5436f5c..4f3c53e 100644 --- a/electron/sync-service.test.ts +++ b/electron/sync-service.test.ts @@ -23,9 +23,14 @@ const cipher: PasswordCipher = { const turn = () => new Promise((resolve) => setImmediate(resolve)); const settle = async () => { for (let index = 0; index < 50; index++) await turn(); }; -// Waits for a condition rather than a fixed number of turns, which a loaded machine can outrun. +// Waits on the clock rather than a count of turns: a slow Windows runner outran 20,000 turns +// before sign-in finished, and the test went on as if it had. async function until(check: () => boolean): Promise { - for (let index = 0; index < 20_000 && !check(); index++) await turn(); + const deadline = Date.now() + 10_000; + while (!check()) { + if (Date.now() > deadline) throw new Error('Timed out waiting for the sync service'); + await turn(); + } await settle(); }