question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling a custom protocol breaks request interception

See original GitHub issue

Describe 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:

  1. Go to: https://codesandbox.io/s/quirky-browser-yjijd
  2. Click on the Start Polling button
  3. Notice that the responses gets intercepted by the mock service worker
  4. Click on anchor tag with the custom protocol mailto: href
  5. Notice that the interceptions stops as the polling continues

Expected behavior

That the mock service worker continues to intercept the calls

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kettanaitocommented, Jan 7, 2022

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.

0reactions
kettanaitocommented, Jan 7, 2022

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: or arbitrary-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.

Going to check on that sponsor link now. ✌️

Huge thanks for sponsoring MSW! 🎉

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found