Skip to content

TypeError when redirect is set to 'manual' #1072

@KhafraDev

Description

@KhafraDev

Bug Description

A TypeError is thrown when using { redirect: 'manual' } (this did work in older versions)

Reproducible By

import { fetch } from 'undici';

const r = await fetch('https://httpbingo.org/redirect-to?url=http%3A%2F%2Fexample.com%2F', {
    redirect: 'manual'
});

console.log(r.headers.get('location'));

Expected Behavior

No TypeError

Logs & Screenshots

\node_modules\undici\lib\fetch\index.js:176
        Object.assign(new TypeError('fetch failed'), { cause: response.error })
                      ^

TypeError: fetch failed
    at Object.processResponse (\node_modules\undici\lib\fetch\index.js:176:23)
    at fetchFinale (\node_modules\undici\lib\fetch\index.js:720:17)
    at EventEmitter.mainFetch (\node_modules\undici\lib\fetch\index.js:695:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  cause: undefined
}

Environment

Windows 10, node v16.11.0, undici v4.8.1

Additional context

without much debugging the status is set as 0 so I suspect it's never updated from its default value for some reason

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions