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
Money risk. A single malformed orderbook_delta or order_group frame (server bug, schema drift, network truncation) silently corrupts local orderbook state with no resync trigger. The seq-gap-driven safety net is bypassed.
_process_frame advances the seq tracker (tracked = True) BEFORE pre-validating the orderbook payload. When OrderbookSnapshotMessage.model_validate / OrderbookDeltaMessage.model_validate raises ValidationError, the recv loop catches it as "malformed WS frame" + continue — but the seq watermark already advanced. The next delta with seq=N+1 matches expected=N+1 and gap detection never fires. The existing rollback only catches KalshiBackpressureError from dispatch, not ValidationError from pre-validation.
order_group_updates has the analogous path through dispatch.py:222-232 (silent swallow, seq already advanced).
Wrap the pre-validate + apply + dispatch block in a try/except that rolls back the seq watermark on any exception (ValidationError, KeyError, programming bugs), not just KalshiBackpressureError. Same shape as the existing rollback branch, broader except clause. Add a regression test that injects a malformed sequenced delta and asserts the next frame triggers gap recovery.
Activity
fix(ws): release orphan subscribe acks; require snapshot yes/no (#268) (