You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Observed once during a full-suite run (npx vitest run) while working on #55; passes in isolation and passed 3/3 subsequent full runs, so it is load-dependent rather than deterministic.
× SsmSession > queues input sent BEFORE handshake completes, then flushes on ready
Cause
src/ssm/session.test.ts:153 waits for an async flush with a wall-clock sleep:
5 ms is enough on an idle machine and not enough when 26 other test files are running in parallel workers. The same pattern appears at :163 and elsewhere in the file, so this is the first one to lose the race, not the only one that can.
Why it matters beyond the noise
A flake here is worse than an ordinary flake because the assertion is about input being queued rather than dropped — the terminal's correctness property. A test that intermittently fails for timing reasons trains everyone to re-run it, which is exactly how a real regression in the flush path would get waved through.
Fix
Replace the sleep with a condition wait — poll for the expected frame with a generous ceiling, so the test's duration tracks the machine rather than its correctness:
asyncfunctionwaitFor(pred: ()=>boolean,ms=1000){constt0=Date.now();while(!pred()){if(Date.now()-t0>ms)thrownewError("timed out waiting for condition");awaitnewPromise((r)=>setTimeout(r,1));}}
Then await waitFor(() => outputFrames(ws).length > 0). Applies to every setTimeout(r, 5) in the file.
Found incidentally; not caused by #55 (reproduced on unmodified main, and the file is untouched by that work).
Activity
fix(ssm): wait on the condition, not on 5ms (#61) (#68)