msw
msw copied to clipboard
`sendBeacon` causes infinite loop with response patching
Prerequisites
- [X] I confirm my issue is not in the opened issues
- [X] I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- [X] I'm using the latest
mswversion - [X] I'm using Node.js version 14 or higher
Browsers
Chromium (Chrome, Brave, etc.), Firefox, Safari
Reproduction repository
https://github.com/hpohlmeyer/msw-send-beacon-loop
Reproduction steps
- Check out the repro:
git clone https://github.com/hpohlmeyer/msw-send-beacon-loop.git - Run
npm installin the root folder - Run
npm start - Go to http://localhost:3002/ in Chrome (FF just freezes without seeing anything in the network tab)
- Open the network tab in the devtools
- Click on the "Trigger request" button
- You will see an infinite request loop
Current behavior
It looks like ctx.fetch(req) does not seem to bypass msw and triggers the same request over and over again, causing an infinite request loop.
Expected behavior
ctx.fetch(req) should bypass msw and not trigger the same route handler again.
Hey, @hpohlmeyer. Thanks for reporting this!
I'm currently overwhelmed with the issues but I will keep this one in mind whenever I have a spare minute. Any volunteers are welcome on this one!