Repository navigation
fix(client): respect abort signals in ordinary localLink calls - #8026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@peterolkhov is attempting to deploy a commit to the trpc Team on Vercel. A member of the Team first needs to authorize it. |
|
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: |
agammann
left a comment
There was a problem hiding this comment.
The new Promise.race changes which result reaches the observer, but runProcedure(op.input) starts before the race. With an already-aborted signal, it still calls createContext() and, after that resolves, callProcedure() even though the caller has received AbortError. A resolver with side effects can therefore run after cancellation. Could the signal be checked before starting runProcedure and again after awaiting context? The new already-aborted test checks rejection only; asserting that the context and resolver were not invoked would cover this. I reviewed the current diff; I did not run tests locally. AI-assisted review.
…8027) ## Why - Follow-up to trpc#8026, which stops the client waiting once a `localLink` call is aborted. The work behind it kept going: - A call aborted before it started still created context and ran the procedure. - A call aborted while `createContext` was pending still ran the procedure once context resolved. A cancelled mutation would still write. - `createContext` got no signal, unlike the adapters' `createContext`, which gets `info.signal`. ## What - `createContext` receives `{ info: { signal } }`, mirroring the adapters. Procedures already get the same signal as `opts.signal`. Existing `() => …` functions still type-check. - Skip context creation and the procedure if the call was already aborted, and skip the procedure if it was aborted during context creation. - Share the existing `throwIfAborted` fallback from `httpUtils`, so runtimes without `AbortSignal.prototype.throwIfAborted` keep working. ```ts localLink({ router, createContext: async (opts) => ({ session: await getSession({ signal: opts.info.signal }), }), }); ``` ## Links - [Local Link › createContext](https://www-git-ccr-71fc9bd5-r732ha-trpc.vercel.app/docs/client/links/localLink#createcontext): documents `info.signal`. ## Alternatives considered - A flat `{ signal }`: simpler, but differs from the adapters' `info.signal`. ## Testing - Regression check: in `localLink.test.ts`, `passes the signal to createContext`, `does not run the procedure when aborted during context creation` and `does not create context or run the procedure when already aborted` fail without this change, for both query and mutation. ## AI model - Claude Opus 5.5 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_019Un67dkX3ZhkgFt8euJr5b --------- Co-authored-by: Claude <[email protected]>
|
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
What
Links
Alternatives considered
Testing
Regression check:
localLink.test.tscovers query and mutation cancellation during pending resolvers, pending context creation, and before a call starts. All six fail without the fix.Full workspace checks remain blocked locally by missing dependencies; package-wide type checks have not passed.
AI model
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit