Repository navigation
fix(server): delete stale clientSubscriptions entry on subscription task rejection - #7401
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
π WalkthroughWalkthroughThis PR fixes a resource leak in the WebSocket subscription adapter where stale entries could accumulate in the ChangesSubscription Error Handler Cleanup
Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes Suggested reviewers
π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
Comment |
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
|
The failing test is in The test expects Could a maintainer re-run CI or confirm this is pre-existing? Happy to rebase if needed. |
adf2e90 to
2216f02
Compare
2216f02 to
3d4268c
Compare
β¦ask rejection When the subscription async task rejects (e.g. iterator.return() throws during disposal), the .catch() handler aborts the controller and sends an error response but never removes the entry from clientSubscriptions. This leaves a stale AbortController in the Map for the connection's lifetime, preventing subscription ID reuse. Fixes trpc#7400
3d4268c to
f692a2a
Compare
|
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. |
Summary
Fixes #7400 β stale
clientSubscriptionsentry after subscription task rejection in WebSocket adapter.Problem
In
packages/server/src/adapters/ws.ts, when the subscription async task rejects (e.g.iterator.return()throws duringawait usingdisposal), the.catch()handler aborts the controller and sends an error response but never callsclientSubscriptions.delete(id). This leaves a staleAbortControllerin the Map for the connection's lifetime, preventing subscription ID reuse.The happy path (line 407) correctly calls
clientSubscriptions.delete(id)β only the error path is missing it.Fix
Add
clientSubscriptions.delete(id)as the first line of the.catch()handler, mirroring the cleanup on the happy path.Changes
packages/server/src/adapters/ws.ts: +1 line in the subscription task.catch()handlerSummary by CodeRabbit