Skip to content

fix(client, openapi): follow redirects by default in fetch transport - #2425

Merged
dinwwwh merged 3 commits into
mainfrom
claude/gifted-knuth-0luga5
Nov 6, 2026
Merged

dinwwwh merged 3 commits into
mainfrom
claude/gifted-knuth-0luga5

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Related to #2421 (the redirect part; the empty-body part is not covered here).

Changes

  • FetchLinkTransport no longer forces redirect: 'manual', so fetch keeps its default and follows redirects. A proxy redirect no longer resolves as the procedure output.
  • The opaque redirect check stays, for a custom fetch that sets redirect: 'manual' in browsers. Its message is clearer.
  • OpenAPILink docs and JSDoc warn that 3xx responses are not returned by default, and show how to get them with a custom fetch using redirect: 'manual' (server runtimes only).
  • The v1 migration guide notes the change (v1 also sent redirect: 'manual').

Behavior change

  • Browsers: a redirect used to throw; it is now followed.
  • Server runtimes: a 3xx used to be returned as the output; it is now followed. Use redirect: 'manual' to keep the old behavior.

Tests

  • A default call does not set redirect, so the request follows redirects.
  • With a custom fetch using redirect: 'manual', a 307 detailed-output procedure resolves to { status: 307, headers: { location }, body: undefined }.

pnpm check, pnpm docs:validate and pnpm test pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VVaw7SxRQUQzZ994Tqbo5a

Stop forcing `redirect: 'manual'` in `FetchLinkTransport`, so `fetch` keeps
its default behavior and follows redirects. Document on `OpenAPILink` that
redirect responses are not reflected by default, and that overriding `fetch`
with `redirect: 'manual'` receives them in server runtimes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7SxRQUQzZ994Tqbo5a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7SxRQUQzZ994Tqbo5a
@pkg-pr-new

pkg-pr-new Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2425

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2425

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@2425

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2425

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@2425

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2425

@orpc/effect

npm i https://pkg.pr.new/@orpc/effect@2425

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@2425

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@2425

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2425

@orpc/experimental-lock

npm i https://pkg.pr.new/@orpc/experimental-lock@2425

@orpc/mcp

npm i https://pkg.pr.new/@orpc/mcp@2425

@orpc/msw

npm i https://pkg.pr.new/@orpc/msw@2425

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2425

@orpc/next

npm i https://pkg.pr.new/@orpc/next@2425

@orpc/node

npm i https://pkg.pr.new/@orpc/node@2425

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2425

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@2425

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@2425

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@2425

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@2425

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@2425

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2425

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2425

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@2425

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2425

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2425

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2425

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2425

commit: 5bee438

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 28 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing claude/gifted-knuth-0luga5 (5bee438) with main (f7a7a2a)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Redirect default in the shared transport — FetchLinkTransport no longer sets redirect: 'manual', so both RPCLink and OpenAPILink inherit fetch's default of following redirects.

  • Opaque redirect guard — the browser-only opaqueredirect rejection stays for custom fetch implementations, reworded to name the cause.

  • Tests — rpc-link.test.ts drops the redirect: 'manual' request assertions, while openapi-link.test.ts adds the default-config case (init carries no redirect, Request.redirect is follow) and a redirect: 'manual' custom-fetch case that returns a 307 detailed output.

  • Docs and JSDoc — a new ## Redirect Responses section in openapi/link.mdx, the retargeted warning in openapi/input-and-output-mapping.mdx, and a @remarks note with an anchor on OpenAPILink.

ℹ️ The opt-in redirect: 'manual' path still decodes a 3xx as success on the RPC link

Nothing here is wrong with this PR — the default path that used to reach this code is gone. Flagging for follow-up on #2421: RPCLinkCodec still treats status < 400 as success, so a caller who copies the new docs' redirect: 'manual' fetch override onto RPCLink again gets the 3xx as the procedure output, which is the silent undefined outcome the issue describes.

Technical details
# 3xx remains decodable as RPC output when redirects are manually disabled

## Affected sites
- `packages/client/src/adapters/standard/rpc-link-codec.ts:149` — `const isOk = response.status < 400`, so any `3xx` that reaches the codec is decoded as `{ kind: 'output' }`.
- `apps/content/docs/openapi/link.mdx:291-302` — the documented `redirect: 'manual'` override is transport-level, so it applies to every `FetchLinkTransport` consumer, `RPCLink` included.

## Required outcome
- Decide whether the redirect half of #2421 is closed only for the default path (current state) or also for the opt-in one. If the latter, treat `3xx` as non-success in `RPCLinkCodec` with a message mirroring the `opaqueredirect` one.

## Open questions for the human (optional)
- Is a first-class `redirect` option on `FetchLinkTransportOptions` preferable to the custom-`fetch` workaround? Not required for this fix, and the docs workaround is sufficient today.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
orpc 5bee438 Commit Preview URL

Branch Preview URL
Nov 05 2026, 02:03 PM

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7SxRQUQzZ994Tqbo5a

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the delta since the previous Pullfrog review (6a6a614): documentation only, one new section in the v1 migration guide.

  • Migrating from v1: fetch links follow redirects — documents that RPCLink and OpenAPILink no longer force redirect: 'manual', shows the custom fetch override that restores the old 3xx-as-output behavior, and links to the OpenAPI Link redirect section.

The "as in v1" claim checks out: @orpc/client@1.16.1's fetch adapter set redirect: 'manual', and v1's OpenAPILink delegates to that same client. The new #redirect-responses anchor resolves under pnpm docs:validate (blume --strict), and no other docs page still describes the old manual behavior.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@dinwwwh
dinwwwh merged commit 2c48e45 into main Nov 6, 2026
12 checks passed
lodgekeeper added a commit to elflodge/elflodge that referenced this pull request Nov 11, 2026
… beta.49

oRPC's fetch transport no longer sets redirect: "manual" (middleapi/orpc#2425), so the link's
check for a 3xx answer can no longer fire.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants