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.

Transparent handler ("*") doesn't allow fall-through

See original GitHub issue

Reproduction step

setupWorker(
  rest.get('*', () => console.log('caught')),
  rest.get('/user', (req, res, ctx) => res(ctx.json({ firstName: 'John' }))
)

Expected behavior

  1. Prints out "caught" in the console.
  2. Returns { firstName: "John" } as the mocked response.

Current behavior

GET /user returns 404 (not handled).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kettanaitocommented, Jul 6, 2020

Yes 💯 Because the first /use* handler matched, but returned no mocked response. So it falls through to the next handler, and /user matches, returning a mocked response. The end result is both "caught" printed into the console and the mocked response.

0reactions
kettanaitocommented, Jul 6, 2020

No. If the /user matches and returns a mocked response, MSW stops iterating down the list of request handlers (current behavior).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Letting a touch "fall through" | Apple Developer Forums
When dealing with touches in SKNodes, sometimes it would be useful in the touchesBegan method of a node to let a touch "fall...
Read more >
noFallthroughCasesInSwitch - explicitly allow fall through
I've enabled the noFallthroughCasesInSwitch option in the tsconfig.json file. That option warned me about an "error", and I want to let the ...
Read more >
break and fallthrough - PVS-Studio
I understand that the possibility not to write break, made to pass control further, allows writing elegant algorithms.
Read more >
Switch/case as a dispatch table with C-style fall-through
Description: I plan to make a collection of various flavors of case/switch/given and package them up for CPAN as one package, probably named ......
Read more >
Attributes in Clang — Clang 16.0.0git documentation
If specified, this attribute allows an advanced developer to tune the ... On x86_64 targets, the callee does not clear the stack, ......
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