msw icon indicating copy to clipboard operation
msw copied to clipboard

`sendBeacon` causes infinite loop with response patching

Open hpohlmeyer opened this issue 3 years ago • 1 comments

Prerequisites

Environment check

  • [X] I'm using the latest msw version
  • [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

  1. Check out the repro: git clone https://github.com/hpohlmeyer/msw-send-beacon-loop.git
  2. Run npm install in the root folder
  3. Run npm start
  4. Go to http://localhost:3002/ in Chrome (FF just freezes without seeing anything in the network tab)
  5. Open the network tab in the devtools
  6. 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.

hpohlmeyer avatar Apr 20 '22 09:04 hpohlmeyer

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!

kettanaito avatar Apr 27 '22 11:04 kettanaito