fix(interceptor): add throwOnMaxRedirect to types and interceptor opts#5066
Open
maruthang wants to merge 1 commit intonodejs:mainfrom
Open
fix(interceptor): add throwOnMaxRedirect to types and interceptor opts#5066maruthang wants to merge 1 commit intonodejs:mainfrom
maruthang wants to merge 1 commit intonodejs:mainfrom
Conversation
The `throwOnMaxRedirect` option was respected per-request inside
`RedirectHandler` but was missing from the TypeScript declarations and
was never plumbed from `redirect({ throwOnMaxRedirect: true })` (the
documented usage). Add it to `RedirectInterceptorOpts`, forward the
interceptor-level default through `dispatchOpts`, and validate the
type. Refs nodejs#4376, nodejs#4377.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5066 +/- ##
==========================================
- Coverage 93.10% 93.09% -0.02%
==========================================
Files 110 110
Lines 35788 35792 +4
==========================================
Hits 33322 33322
- Misses 2466 2470 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Friendly nudge @mcollina — approval + green CI + codecov happy. Ready to land whenever convenient. 🙏 |
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.
This relates to...
Fixes #4376. Continues the work from the now-closed #4377 (author abandoned after #4924 merged the docs in the opposite direction).
Rationale
Issue #4376 reported that
throwOnMaxRedirectwas missing from the TypeScript declarations, and that the documented usageredirect({ maxRedirections: 3, throwOnMaxRedirect: true })did not actually work because the interceptor-level default was never plumbed through to the underlyingRedirectHandler.After #4924 settled the canonical name as
throwOnMaxRedirect(singular, matching existing code), the remaining gaps are:RedirectInterceptorOptsintypes/interceptors.d.ts, so TypeScript users get a compile error when following the docs.lib/interceptor/redirect.jsonly acceptsmaxRedirectionsas a default;throwOnMaxRedirectset on the interceptor itself is silently dropped — only the per-request value works.RedirectHandlerdoes not validate the option type.Changes
Bug Fixes
throwOnMaxRedirectfromcreateRedirectInterceptordefaults throughdispatchOptssoredirect({ maxRedirections: 3, throwOnMaxRedirect: true })behaves as documented.throwOnMaxRedirect?: booleantoRedirectInterceptorOptsintypes/interceptors.d.ts.opts.throwOnMaxRedirectinRedirectHandlerand throwInvalidArgumentError('throwOnMaxRedirect must be a boolean')for non-boolean values.tsdtype test forRedirectInterceptorOpts.Status
docs/docs/api/Dispatcher.mdafter docs: update broken links in file "Dispatcher.md" #4924; this PR makes the docs functional)