-
-
Notifications
You must be signed in to change notification settings - Fork 663
Description
Bug Description
Documentation on main
references a throwOnMaxRedirects
field that can be set on the RedirectInterceptorOpts
to throw an error if the maximum number of redirects are reached. I do not see throwOnMaxRedirects
in the undici code aside from where it's mentioned in that documentation. That field seems to not be defined on the RedirectInterceptorOpts
.
I do however see throwOnMaxRedirect
(no trailing s
) that is actually used to trigger exceptions. Just like throwOnMaxRedirects
, throwOnMaxRedirect
is not defined in the interceptor.d.ts
type declarations/definitions for the pre-defined redirect interceptor opts.
Reproducible By
$ git clone https://github.com/nodejs/undici
$ grep -wrn 'throwOnMaxRedirects' ./undici
./undici/docs/docs/api/Dispatcher.md:965: redirect({ maxRedirections: 3, throwOnMaxRedirects: true })
$ grep -wrn 'throwOnMaxRedirect' ./undici
./undici/test/interceptors/redirect.js:456: throwOnMaxRedirect: true
./undici/test/redirect-request.js:416: throwOnMaxRedirect: true
./undici/lib/handler/redirect-handler.js:95: if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) {
const res = await request(urlToFetch, {
...opts,
dispatcher: getGlobalDispatcher().compose(
interceptors.redirect({
maxRedirections: 1,
throwOnMaxRedirects: true
})
),

Expected Behavior
-
Documentation specifies how someone can properly trigger an exception using either
throwOnMaxRedirect
orthrowOnMaxRedirects
(not sure which one is correct, but personal preference isthrowOnMaxRedirects
-
RedirectInterceptorOpts
are updated to accept an optionalthrowOnMaxRedirects
(orthrowOnMaxRedirect
if that's the preference) boolean for typescript users
Logs & Screenshots



Environment
macOS Sequoia 15.5 (24F74)
pnpm 10.11.0
node 24.2.0
undici 7.13.0