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.

getting an unhandled request error for requests that are handled but intended to be forwarded on

See original GitHub issue

Describe the bug

When using server.listen({onUnhandledRequest: 'error'}), I expect to see errors when there’s an unhandled request, but not when the request is handled with a return undefined.

Environment

  • msw: 0.27.1
  • nodejs: 14
  • npm: 6

Please also provide your browser version.

To Reproduce

Steps to reproduce the behavior:

  1. Clone https://github.com/kentcdodds/msw-handler-error-bug
  2. Install
  3. Run node index.js
  4. See error when mock = false but no error when mock = true

Expected behavior

There should be no error

Screenshots

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
kentcdoddscommented, Apr 13, 2022

Ah, dang. I think this is above my level of experience 😬

1reaction
marcosvega91commented, Mar 19, 2021

an idea could be to add a new method to response object like

const server = setupServer(
  rest.get('https://randomuser.me/api', (req, res, ctx) => {
    if (!mock) return res.forward()
    return res(ctx.json({mocked: true}))
  }),
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

getting an unhandled request error for requests that are handled but ...
When using server.listen({onUnhandledRequest: 'error'}) , I expect to see errors when there's an unhandled request, but not when the request is handled with...
Read more >
MSW logging warnings for unhandled Supertest requests
In my case, as all of my Supertest requests were to /api endpoints, that looked like: beforeAll(() => server.listen({ onUnhandledRequest: ...
Read more >
Add "ctx.forward" for forwarding (bypassing) requests #676
See getting an unhandled request error for requests that are handled but intended to be forwarded on #655. Currently bypassing is done via...
Read more >
WebDriver - W3C
WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral ...
Read more >
Web service error codes (Microsoft Dataverse) - Power Apps
Message: There was a problem with the server configuration changes. Users can continue using the application, but may experience difficulties, ...
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