From b94fa0892c4d50bb217e650f26d24b9a6c5dc0e7 Mon Sep 17 00:00:00 2001 From: os-zhuang Date: Fri, 10 Jul 2026 16:07:33 +0800 Subject: [PATCH] =?UTF-8?q?test(objectql):=20de-flake=20hook-binder=20fire?= =?UTF-8?q?-and-forget=20=E2=80=94=20ordering=20assertion=20instead=20of?= =?UTF-8?q?=20wall=20clock=20(#2744)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test asserted the wrapped after-event call returned in <20ms; shared CI runners exceed that (observed 23ms on PR #2742), failing an unrelated PR. Replace with an ordering assertion: right after the wrapper resolves, the handler's side effect must not have happened yet — the handler's 30ms timer is a macrotask and cannot fire between the wrapper's resolution and the synchronous check, so this is deterministic regardless of runner speed, while still failing if the wrapper ever starts awaiting the handler (calls would already hold 'done'). Closes #2744. Co-Authored-By: Claude Fable 5 --- packages/objectql/src/hook-binder.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/objectql/src/hook-binder.test.ts b/packages/objectql/src/hook-binder.test.ts index eeb579a0ed..ccdbcd5c2f 100644 --- a/packages/objectql/src/hook-binder.test.ts +++ b/packages/objectql/src/hook-binder.test.ts @@ -219,9 +219,13 @@ describe('wrapDeclarativeHook', () => { }, }; const wrapped = wrapDeclarativeHook(meta, meta.handler as any); - const t0 = Date.now(); await wrapped(makeCtx({ event: 'afterInsert' })); - expect(Date.now() - t0).toBeLessThan(20); // returned before handler finished + // Ordering, not wall clock (#2744): if the wrapper had awaited the + // handler, `calls` would already hold 'done' here — the 30ms timer is a + // macrotask and cannot fire between the wrapper's resolution and this + // synchronous check, no matter how slow the runner is. The old + // `< 20ms` wall-clock assertion was flaky on shared CI machines. + expect(calls).toEqual([]); // returned before handler finished await new Promise((r) => setTimeout(r, 60)); expect(calls).toEqual(['done']); });