perf(streams): connect WebSocket after first write (#4104)
## Summary & Motivation Keeps WebSocket setup off the first stream group, then starts the background upgrade when the second HTTP request is dispatched. Later groups continue over HTTP without waiting until the socket is OPEN, when the serialized writer switches transports at a confirmed request boundary. One-group streams never create a socket. An ambiguous HTTP outcome poisons the writer and retires any provisional socket before it can carry a frame. Initial upgrades have a dedicated 10-second background timeout; the existing 250ms bound remains scoped to reconnects after an established socket closes. WS write spans include chunk sequence and count for direct takeover analysis. ## Test Plan Tests cover dispatch overlap, continued HTTP writes while connecting, one-group streams, close during background connection, ambiguous HTTP outcomes, timeout and late OPEN behavior, and trace propagation. The world-vercel suite and typecheck pass locally.
A
Alex Langenfeld committed
5fc8fb7a9866597d62d99ea61bc72dfa9238e6bd
Parent: 01fa7a4
Committed by GitHub <noreply@github.com>
on 9/11/2026, 5:03:54 PM