fix: preserve WebSocket send queue byte accounting during flush (#3688)
## Summary Keep queued and in-flight messages charged to the existing byte limit until each send succeeds. Serialize overlapping flushes, preserve FIFO restoration on errors or cancellation, and keep concurrent drains from releasing pending-message capacity. The change is confined to the shared SendQueue helper and focused queue/reconnect tests. It preserves ordinary enqueue/backpressure behavior and does not change generated connection APIs, logging, dependencies, or Python support. This PR targets public main independently; no stacking dependency. ## Validation - 34 focused synchronous/asynchronous queue and mocked reconnect tests passed, covering all six GA/beta Responses and Realtime connection classes. - Repository-wide Ruff, mypy (1,562 source files), and pinned Pyright passed; changed-file formatting and git diff checks passed. - Separate read-only Codex review round 1 was clean (no actionable P0–P2 findings), including 20 repeated focused-suite runs. - Local environment used the exact committed frozen lockfile because the public-main lock freshness check requested an update; no dependency files changed. ## Generation follow-up SDK CODEOWNER review requested. Carry the shared-helper accounting behavior and regression coverage into the corresponding Castiron source/template so regeneration preserves it; no generated resource patch is needed here.
A
Alex Chang committed
96f966d77bddc7449ae23fda5b29ef44c3f98cc2
Parent: f36e6f7
Committed by GitHub <noreply@github.com>
on 8/19/2026, 9:19:13 PM