-
-
Notifications
You must be signed in to change notification settings - Fork 604
Closed
mswjs/interceptors
#581Labels
bugSomething isn't workingSomething isn't workingneeds:triageIssues that have not been investigated yet.Issues that have not been investigated yet.scope:nodeRelated to MSW running in NodeRelated to MSW running in Node
Description
Prerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- I'm using the latest
mswversion - I'm using Node.js version 18 or higher
Node.js version
v20.12.2
Other versions
msw - 2.3.1
axios - 1.7.2
Reproduction repository
https://codesandbox.io/p/devbox/axios-follow-redirects-issue-9qn7z9
Reproduction steps
- Setup a http.get response handler that responds with a redirect (HttpResponse.redirect or
new Responsewith 3xx code and Location header) - Make a GET request to the URL specified in the handler
Current behavior
The request fails with this error message originating from the follow-redirects library Axios uses
Error [ERR_FR_REDIRECTION_FAILURE]: Redirected request failed: Cannot read properties of undefined (reading 'getHeader')
The stack trace points to this line in the follow-redirects lib
https://github.com/follow-redirects/follow-redirects/blob/35a517c5861d79dc8bff7db8626013d20b711b06/index.js#L422
response.req.getHeader is undefined in the IncomingMessage/response follow-redirects receives when the response is mocked using MSW. This does not happen when the requests returning redirects are not intercepted with MSW.
Expected behavior
Axios should be able to follow redirects normally like it does when responses are not mocked with MSW.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds:triageIssues that have not been investigated yet.Issues that have not been investigated yet.scope:nodeRelated to MSW running in NodeRelated to MSW running in Node