Calling a custom protocol breaks request interception
See original GitHub issueDescribe the bug
If a link to a custom protocol (i.e. mailto:) is triggered on a page, then the mock service worker stops intercepting requests.
Environment
msw: 0.36.3
chrome: 97.0.4692.71
firefox: 95.0.2
To Reproduce
Steps to reproduce the behavior:
- Go to: https://codesandbox.io/s/quirky-browser-yjijd
- Click on the Start Polling button
- Notice that the responses gets intercepted by the mock service worker
- Click on anchor tag with the custom protocol mailto: href
- Notice that the interceptions stops as the polling continues
Expected behavior
That the mock service worker continues to intercept the calls
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
10 Using Service Interceptors to Manipulate Requests
When the decision is made to abort a request, the interceptor breaks the chain for that request. The request is rolled back through...
Read more >Intercepting and Modifying responses with Chrome via the ...
First, we'll need to register what we want to intercept by submitting a list of RequestPatterns to setRequestInterception. You can intercept at ...
Read more >Request Interception - Puppeteer
This first handler will succeed in calling request.continue because the request interception has never been resolved. ... // The interception has not been...
Read more >Intercept and modify REST calls :: SDKs - ForgeRock Backstage
The ForgeRock SDKs support modification of REST calls before they are sent. ... public protocol RequestInterceptor { func intercept(request: Request, ...
Read more >Can you intercept NSURLRequests in a UIWebView without ...
I'm having trouble loading custom HTML into my UIWebView without breaking its goBack method. What Works. I'm intercepting the URL requests of my...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve just tested this sandbox in another browser without any mailing clients configured. Clicking on the anchor opens my mailing client in another browser, preserving the sandbox. The polling keeps going after this, as the page’s context wasn’t destroyed.
That’s a valid concern. Interacting with custom protocols must not interfere with the request interception, given the page’s context is preserved. I don’t think the protocol interaction is the issue, though. Resources that are not requested will not be handled by the worker, so clicking on
mailto:
orarbitrary-protocol:
links doesn’t trigger the “fetch” even in the worker to cause any kind of trouble. Perhaps try looking into the surrounding parts of the mocking setup and your app logic that may cause the mocks to break? Maybe there are some exceptions going on that could stir the investigation into the right direction.Huge thanks for sponsoring MSW! 🎉