-
-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ServiceWorker doesn't catch routes in Firefox only #220
Comments
Hey, @LeBenLeBen. Thanks for reporting this. I've tried to reproduce this behavior using the REST - Params example in Firefox 77.0.1 (64-bit). However, instead of
|
Meanwhile, may I please ask you to remove the That way we can triage where the problem is. Thanks. |
Thanks for replying so quickly! I hard coded the URL to mock to be What is weird is that if I add some logging in the SW, at the very beginning of the console.warn('Catch fetch for', request.url); The URL I’m trying to mock doesn't event show up in the logs:
Isn't supposed to show up here as other resources? It's like Firefox doesn't let that request go into the SW at all. |
That's strange. May I please ask you to add Line 74 in 638874a If that doesn't print anything out, it's either SW is not properly registered, or there's an issue between browser and the worker. If it does print something out (which I hope), I'd recommend checking what happens later, during the response: Lines 83 to 94 in 638874a
Sorry for asking to do this, I cannot seem to reproduce it in Firefox myself. I'm testing using the REST Query parameters example. |
I was able to make Firefox mock the request by running I checked both requests to find differences, and basically the one that fails is an XMLHttpRequest whereas the one that works is done with Fetch. This leaded me to find that XHR within SW are not supported in Firefox apparently, which match with my logs not outputting the XHR request at all from the SW. I guess we'll have to either use Fetch or Chrome then 😅 |
Thanks for finding that, @LeBenLeBen! I didn't know that Firefox limitation. Glad that the issue could be resolved :) |
@kettanaito it seems this is not resolved still? do you have any workaround for Firefox to make it work? |
@Thane2376 It’s a browser limitation, no workaround is possible, you should either use Fetch or another browser. |
@Thane2376, as rightfully pointed, it’s a Firefox-specific limitation. We will not provide any workarounds for that, as we don’t ship browser- and framework-specific logic. |
We had a situation where FF would not redirect and Chrome did which caused us problems that had us scratching our heads. Our setup had an XHR within a service worker. Thanks for your post and cause analysis, it helped us track down the issue. We also found, that although the redirect would not work on one tab in FF it did on any other tab instance. If we get time we'll try and figure out why that's the case. |
Describe the bug
MSW properly mock routes in Chrome and Safari, but doesn't in Firefox.
Environment
msw: 0.19.3
nodejs: 12.14.0
npm: 6.14.2
firefox: 77.0.1
To Reproduce
Here’s my
mocks.js
file:The request is made with Axios within a Vue.js generated with Vue CLI and using TypeScript. It basically looks like this:
I tried to put some logs in the ServiceWorker and it seems to not catch this request at all while seeing others such as assets.
I'm testing in HTTP but I have checked the parameter to enable SW in HTTP in the devtools. I have also cleared the SW after every change in
about:debugging
to be sure it was up-to-date.Expected behavior
The request should be mocked in Firefox just like it does in Chrome and Safari.
Screenshots
Firefox console:
Chrome console:
The text was updated successfully, but these errors were encountered: