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.

Add a debugging request handler

See original GitHub issue

Is your feature request related to a problem? Please describe.

One of the most common issues developers experience is unmatched requests.

Describe the solution you’d like I suggest to add a debugger request handler (i.e. log) that would act as a transparent handler, meaning it would log out any requests that didn’t match preceding handlers.

Describe alternatives you’ve considered We usually suggest to do that manually, but neither of the existing handlers can be fully used as a transparent request handler, as they have a predicate built-in which limits requests captured to a certain degree.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
kettanaitocommented, Mar 12, 2021

I believe there are multiple strategies the users may be choosing when installing MSW:

  • Mock-first, no backend at all, develop entirely against MSW. Here I don’t want any unhandled requests to happen.
  • Incremental, there’s an existing app, there’s a backend, let’s use MSW to either extend that backend or mock a third-party service. Here I’d expect my unhandled requests to happen, so there are no distractions to my flow.
  • Testing. I’ve got an app, I need to write some tests in Node.js. Here I don’t want any unhandled requests to happen.

From the use-cases, I see the default onUnhandledRequest option would be beneficial to most of them. That being said, it’d be nice to see how many people follow each of those strategies to evaluate our choice.

The fact that misconfigured request URLs cause 80% of mismatch issuses is a huge reason to set onUnhandledRequest: "warn". That’d be both non-invasive, but informative.

2reactions
kettanaitocommented, Mar 2, 2021

I think in most of the cases, when MSW is introduced to a project, it’s the intention to mock all the API requests

What about the mock-driven development? Although unexplored, I find it a promising direction and can see people developing against MSW until their backends are ready. Wouldn’t seeing a bunch of warnings be annoying?

I do share the idea to set “warn” as the default unhandled request policy, it’d ease the debugging curve for people experiencing uncaught requests. I just wish for us to think through all the implications of that change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging uncaught requests - Recipes - Mock Service Worker
Debugging uncaught requests · Enable onUnhandledRequest option · Examine the handlers · Verify the worker's scope · Run in debug mode.
Read more >
Debugging a HTTP Handler from Visual Studio - Stack Overflow
Publish the handler to its own IIS application and then attach Visual Studio to IIS and you're ready to debug.
Read more >
Debugging a HTTP Handler - MSDN - Microsoft
I start my Web Application using any random page in Visual Studio Debug. I then maually edit the URL to point to the...
Read more >
How do I debug a http handler? - CodeProject
You can debug it just like any other piece of code. Put a break point in the handler run in debug. I've written...
Read more >
Advanced Features: Debugging - Next.js
Once the server starts, open a new tab in Chrome and visit chrome://inspect , where you should see your Next.js application inside the...
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