Skip to content

Commit 99e3cda

Browse files
committed
test(redis): prove waiter accounting by the teardown a timed-out waiter must perform
The settle path clears the memo on its own, so a drifted waiter count only shows when a later lone waiter times out and fails to tear the signal down. Exercise that path directly; the test now fails without the per-waiter guard.
1 parent afca7b5 commit 99e3cda

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

apps/sim/lib/execution/execution-signal.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,12 @@ describe('ExecutionSignalHub', () => {
460460
expect(againSettled).not.toHaveBeenCalled()
461461
expect(mockSubscribe).not.toHaveBeenCalled()
462462

463-
connection.status = 'ready'
464-
connection.client?.emit('ready')
465-
await again
466-
// The reconnect also re-subscribes the surviving channel; what matters is
467-
// that the new one went out only once readiness was genuinely observed.
468-
expect(mockSubscribe).toHaveBeenCalledWith(
469-
'execution:signal:execution-again',
470-
'execution:cancel'
471-
)
463+
// And when that lone waiter gives up, it must be the one that tears the
464+
// signal down — which only holds if every earlier waiter left exactly once.
465+
await vi.advanceTimersByTimeAsync(1)
466+
await expect(again).rejects.toThrow('Timed out waiting for Redis subscriber readiness')
472467
expect(connection.client?.listenerCount('ready')).toBe(1)
468+
expect(connection.client?.listenerCount('end')).toBe(0)
473469
expect(vi.getTimerCount()).toBe(0)
474470
} finally {
475471
vi.useRealTimers()

0 commit comments

Comments
 (0)