From 9eac5ecf01e4d26b769403e30188064e0c669857 Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Thu, 5 Nov 2026 00:21:12 +0100 Subject: [PATCH] test: wait for the first read before starting the other edit history sessions The gate belonged to whichever read arrived first, and sessions load their stores independently, so under CI timing another session took it, the loop never reached release() and the test timed out (master, CI run 41930703100). The code cannot block one session on another: sync() only waits on its own slot. Co-Authored-By: Claude Opus 5.5 --- test/edit-history-sync.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/edit-history-sync.test.ts b/test/edit-history-sync.test.ts index 4a9f6266..60cd745b 100644 --- a/test/edit-history-sync.test.ts +++ b/test/edit-history-sync.test.ts @@ -428,14 +428,20 @@ describe('EditHistorySync', () => { host.append('main', editLine('t1', T0, '/w/a.ts')); const orig = host.read; let first = true; + let inRead!: () => void; + const reachedRead = new Promise((r) => (inRead = r)); host.read = async (...a) => { if (first) { first = false; + inRead(); await gate; } return orig(...a); }; const slow = sync.sync(local); + // Only once s1 holds the gate: the sessions load their stores independently, so a later one + // could reach the read first, take the gate and hang the loop below before `release()`. + await reachedRead; for (let i = 1; i <= MAX_LOADED_STORES + 1; i++) await sync.sync({ ...local, id: `s1-${i}` }); release(); expect(await slow).toEqual({ state: 'ok' });