fix(platform): document and surface redirect behavior for HttpClient.followRedirects#6235
Conversation
…followRedirects Fixes Effect-TS#6231
🦋 Changeset detectedLatest commit: c401b12 The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
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 |
|
Picking up shape (2) was the read I'd hoped for after the option tree on #6231; the |
|
This PR description doesn't match the code in the PR - there's no new maxRedirects option implemented. |
Summary
HttpClient.followRedirectshad 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 amaxRedirectsparameter, 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 amaxRedirectsoption and expose it on thefollowRedirectsAPI. Default remains 10.packages/platform-node/src/HttpClient.tsandpackages/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.tsJSDoc - document the platform difference and the newmaxRedirectsknob.Fixes #6231