From 79e496e79dd08bc50f2b17359131fcfd918624bf Mon Sep 17 00:00:00 2001 From: Juan Castro Date: Wed, 30 Sep 2026 16:36:57 -0400 Subject: [PATCH] test: wait on the gap marker rather than a depth that never moves MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The refused-delivery test waited for `depth(subId)` to reach 1 before claiming the marker, but `discard` removes the entry and appends the marker in its place, so the depth is 1 before, during and after. The wait returned at once, and the claim came back `inflight` — the refused delivery still held the lease it was invoked on — leaving the assertion reading `undefined`. It only passed on the slack in `invoked`'s poll interval, which a loaded runner takes away. Waiting on the claim itself is the barrier the depth was standing in for. Dropping `answer = 200` with it: `beforeEach` already resets it, and a redelivery settling before the last assertion would clear the failure count it reads. --- .../events/workerInvoker.integration.test.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/backend/services/events/workerInvoker.integration.test.ts b/src/backend/services/events/workerInvoker.integration.test.ts index e06069f88..688bb8778 100644 --- a/src/backend/services/events/workerInvoker.integration.test.ts +++ b/src/backend/services/events/workerInvoker.integration.test.ts @@ -556,15 +556,16 @@ describe('what each answer does to the delivery', () => { // The event is gone and a marker stands in its place, so the // subscription learns there was one rather than reading silence. + // Waited on by claiming it: depth is 1 across the swap either way. await waitUntil(async () => - expect(await pending().depth(subId)).toBe(1), + expect( + (await pending().claim(subId, { leaseMs: 0 }))?.event, + ).toMatchObject({ + op: 'gap', + reason: 'handler_rejected', + }), ); - answer = 200; - const claimed = await pending().claim(subId, { leaseMs: 0 }); - expect(claimed?.event).toMatchObject({ - op: 'gap', - reason: 'handler_rejected', - }); + expect(await pending().depth(subId)).toBe(1); // It counted: a refusal is still a handler that did not work. await expect( env.server.clients.redis.get(`ev:qf:{${subId}}`),