Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
cursor
Bot
force-pushed
the
cursor/refactor-resolve-response-2443
branch
from
November 4, 2026 23:30
30951ec to
29365d3
Compare
This was referenced Nov 4, 2026
…s values and disposable stream bodies Co-authored-by: alexander <[email protected]>
…t streams Co-authored-by: alexander <[email protected]>
…ror of its call Co-authored-by: alexander <[email protected]>
…er it Co-authored-by: alexander <[email protected]>
Co-authored-by: alexander <[email protected]>
Co-authored-by: alexander <[email protected]>
…ror response that replaces a failed response Co-authored-by: alexander <[email protected]>
cursor
Bot
force-pushed
the
cursor/refactor-resolve-response-2443
branch
from
November 5, 2026 00:53
29365d3 to
8891071
Compare
meefs
pushed a commit
to meefs/trpc
that referenced
this pull request
Nov 5, 2026
…s or errorFormatter throws (trpc#7931) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> 🤖 ## Why - With the standalone, Express and Next.js adapters, a streamed body that fails after its headers were sent made `internal_exceptionHandler` write a second response. Node then threw an uncaught `write after end`, and the process exited. One cause is a JSONL value that `JSON.stringify` can't handle, such as a `bigint`. - A throwing `errorFormatter` made the same handler throw. The request got no response, and the rejection was unhandled. ## What - `internal_exceptionHandler` only ends a response whose headers were already sent. - If the error formatter throws, it answers with a minimal `INTERNAL_SERVER_ERROR` that reveals nothing about the error, like the ws adapter since trpc#7915. ## Links None ## Alternatives considered - Make a JSONL value that can't be serialized fail only its own call. That's a bigger change to the stream producer, so it goes into the `resolveResponse` rewrite (trpc#7894) instead. ## Testing Regression check: both tests in `nodeHTTPExceptionHandler.test.ts` fail on `main`. The first records the uncaught `write after end`. The second never gets a response. ## AI model Claude Opus 5.5 <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-2b80ea20-543b-539a-ac42-4d10f7dc2443?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-2b80ea20-543b-539a-ac42-4d10f7dc2443&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> <!-- codesmith:footer --> --- <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1796427726&installation_model_id=443568&pr_number=7931&ref=codesmith_pr_footer&repository=trpc%2Ftrpc&return_to=https%3A%2F%2Fgithub.com%2Ftrpc%2Ftrpc%2Fpull%2F7931&signature=9083b9aa072e878edd679cb7f25b81100e7198516eb090ce2d67ba26595082da"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png" width="190" height="28"></picture></a> <sup><a href="https://app.blacksmith.sh/trpc/codesmith/trpc/pr/7931?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved error handling when generating error responses fails, avoiding uncaught errors and duplicate responses. * If error formatting fails, the request now receives a safe internal server error response with HTTP status 500. * Streamed responses that fail during serialization are handled safely, including when response headers have already been sent. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Cursor Agent <[email protected]>
meefs
pushed a commit
to meefs/trpc
that referenced
this pull request
Nov 17, 2026
…disconnects (trpc#8062) ## Why - When a client disconnects mid-body, the node-http adapters hang: the procedure never runs, `onError` never fires, and the body promise leaks. The body `ReadableStream` only listened to the source stream's `data`/`end`, so an aborted or failed source stream never ended it, and `await req.text()` in the JSON content type waited forever. ## What - `createBody()` now also listens to the source stream's `error` and `close` events, and ends the `ReadableStream` with a `CLIENT_CLOSED_REQUEST` error when the stream goes away before a clean `end`. - Clean `end` still closes the stream as before; `close` after `end` is ignored via `readableEnded`. - This is the request-body layer only, orthogonal to the response-pipeline rewrites in trpc#7894 and trpc#7934. ## Links - None ## Alternatives considered - Every consumer racing `req.text()` against the request's abort signal — lost: the stream knows when it dies; ending it once at the source fixes every reader. ## Testing - Regression check: `packages/tests/server/adapters/standalone.test.ts > calls onError when the client disconnects mid-body` fails on main (waits 1.5s, `onError` never fires); passes with this change. - `packages/server/src/adapters/node-http/incomingMessageToRequest.test.ts > rejects the body when the client disconnects mid-body` also fails without the fix. ## AI model glm-5.3 <!-- codesmith:footer --> --- <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1797402378&installation_model_id=443568&pr_number=8062&ref=codesmith_pr_footer&repository=trpc%2Ftrpc&return_to=https%3A%2F%2Fgithub.com%2Ftrpc%2Ftrpc%2Fpull%2F8062&signature=31f1dd129d5234cf4ac42309680374db1d04a57b0bb61454adb6de2647121f86"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png" width="190" height="28"></picture></a> <sup><a href="https://app.blacksmith.sh/trpc/codesmith/trpc/pr/8062?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Requests interrupted while the client is sending a body now fail promptly with a clear error instead of potentially hanging. * Interrupted requests are reported through the server’s error handling, and the affected procedure does not run. * Request streams are cleaned up after completion, errors, or premature disconnects, helping interrupted requests close reliably. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pengzh1 <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Alexander Johansson <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Draft for discussion, not for merge.
Why
resolveResponsewas one 850-line function: onetry/catch, error handling copied four times, stream cleanup wired by hand.What
Resultvalues;settle()holds the onlytry/catch.maxDurationMstimer areusingresources. No polyfill orlibchange.onErrorruns once when a subscription fails before streaming. A stream overhttpLinkorhttpBatchLinkfails only its call, keepingpath. A single call's error gets its procedure's type.responseMetaruns at most once.responseMeta, the 500 dropsresponseMeta's and the stream's headers, keepingvary,allowandcreateContextheaders.Links
None
Alternatives considered
Promise.allreads more clearly.DisposableStack: missing on Node 18 and 20, and the build doesn't lower it.Testing
Each fix's test in
resolveResponse.regressions.test.tsfails on the commit before it;getRequestInfo's change is enforced by typecheck.AI model
Claude Opus 5.5
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.