Repository navigation
fix(client): don't flush a later WebSocket request onto a connecting socket - #7911
Conversation
…socket After a batch fails because its socket closed, a sibling request's flush can still be waiting on its sleep(0) timer. When it fires, it sent requests queued for the new socket while that socket was still connecting, failing them with "Active connection is not open". A run whose own request was already sent now leaves the queue alone when the socket isn't open; each queued request's own run sends it once the socket opens. Co-authored-by: Alex / KATT <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
trpc-bot
left a comment
There was a problem hiding this comment.
🤖 Approved; Alex approved this fix.
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Why
wsClientrequest starts its own flush run: wait for the socket,sleep(0), then send the queue. After a batch fails because its socket closed, a leftover run can flush a new request onto the next socket while it's still connecting, and the request fails withActive connection is not open.main(472e6ba) alone, separate from fix(client): isolate retired WebSocket close and error events #7727 and fix(client): fail or resend only the requests sent on a closing WebSocket #7910.What
batchSend: aftersleep(0), if the socket isn't open and this run's own request was already sent, return without flushing. Each queued request's own run sends it once the new socket opens.RequestManager.isOutgoing(message)checks whether a message is still queued.Links
None
Alternatives considered
Testing
Both tests in
websockets.flushAfterBatchFailure.test.tsfail onmain472e6ba withActive connection is not openin 30/30 runs, and pass with the fix.AI model
Claude Opus 5.5
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit