Replies: 2 comments 2 replies
-
Hi, @jkieboom. That's an interesting observation. To clarify: we're speaking about running MSW in the browser, correct? It looks like we should halt any deferred requests if the user calls We should also add an escape logic in |
Beta Was this translation helpful? Give feedback.
-
Yes, forgot to mention that.
Hmm, but then it would wait for the wrong predicate promise? |
Beta Was this translation helpful? Give feedback.
-
Asking as a discussion because I don't have a standalone repro case yet. I'm running into an issue where the
window.fetch
patching will run on top of an already patchedfetch
(frommsw
itself):msw/src/utils/deferNetworkRequestsUntil.ts
Lines 23 to 28 in 115b435
I'm setting up MSW in
beforeEach
(teardown inafterEach
) and if a test does not make any network request that would wait for MSW to be setup, it is possible for thefetch
patching to happen twice. It looks likestop
does not "abort" the network request deferral.I'm currently working around the issue by polling for "window.fetch" to be the native fetch again, after calling
stop
, but I feel this is a bug inmsw
fundamentally.Beta Was this translation helpful? Give feedback.
All reactions