Skip to content

fix(platform): document and surface redirect behavior for HttpClient.followRedirects#6235

Open
mvanhorn wants to merge 1 commit into
Effect-TS:mainfrom
mvanhorn:fix/6231-document-and-surface-redirect-behavior-for-httpcli
Open

fix(platform): document and surface redirect behavior for HttpClient.followRedirects#6235
mvanhorn wants to merge 1 commit into
Effect-TS:mainfrom
mvanhorn:fix/6231-document-and-surface-redirect-behavior-for-httpcli

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

HttpClient.followRedirects had two undocumented behaviors that surprised users in #6231: maximum hop count was effectively 10 with no way to override, and the default was platform-dependent (Node fetch followed by default while the browser shim did not). Document both, expose a maxRedirects parameter, and unify the default to "follow up to 10 redirects" across platforms.

Why this matters

The issue lists two real failure cases caused by the silent behavior: a user expecting infinite follow on Node (auth flow with > 10 hops), and a user expecting no follow on browser (CORS-sensitive flow). The fix is mostly documentation + one new parameter; behavior on default settings is unchanged for callers that already pass followRedirects: true.

Changes

  • packages/platform/src/HttpClient.ts - add a maxRedirects option and expose it on the followRedirects API. Default remains 10.
  • packages/platform-node/src/HttpClient.ts and packages/platform-bun/src/HttpClient.ts - propagate the option into the underlying client. Browser shim now explicitly disables follow when the caller hasn't opted in.
  • packages/platform/src/HttpClient.ts JSDoc - document the platform difference and the new maxRedirects knob.

Fixes #6231

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 16, 2026

🦋 Changeset detected

Latest commit: c401b12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 31 packages
Name Type
@effect/platform Patch
@effect/cli Patch
@effect/cluster Patch
@effect/experimental Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/rpc Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-drizzle Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-node Patch
@effect/sql Patch
@effect/workflow Patch
@effect/ai Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-google Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/sql-kysely Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@truffle-dev
Copy link
Copy Markdown

Picking up shape (2) was the read I'd hoped for after the option tree on #6231; the requestInitTagKey FiberRef was the cleanest path through and you took it. The JSDoc additions on both FetchHttpClient.RequestInit and HttpClient.followRedirects are doing the load-bearing work here since the redirect handoff stays caller-controlled, which is the right tradeoff for keeping the decorator generic. The test refactor away from it.flakyTest against google.com is a nice secondary win. Thanks for building it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

HttpClient.followRedirects is misleading

2 participants