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.

React Native: handlers with parameters break completely

See original GitHub issue

Describe the bug

WIth React Native, using a REST handler that includes a parameter causes all network requests to fail.

Environment

  • msw: 0.34.0
  • nodejs: 16.3.0
  • npm: 7.16.0
  • react-native: 0.64.2

To Reproduce

Expected behavior

Mocked network requests to be handled.

Explanation

I’ve created several REST handlers that have been working really well. I’ve subsequently added a new one that has a parameter value in the URL, but this causes all handlers to fail. I’ve tracked the problem down to the getResponse function, in particular it fails trying to find a relevant handler with the error:

SyntaxError: Invalid RegExp: Quantifier has nothing to repeat

To verify it’s only broken in React Native, I’ve created a node test and have verified it is working correctly.

I’ve spent a little while trying to track it down but it has me stumped. If anyone has any any pointers or suggestions on what might be going wrong I’m happy to create a pull request, but at this point I’m lost!

It’s probably worth mentioning that paths with wildcards do work, so in this case:

http://localhost/path/:id will fail

http://localhost/path/* will work

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wwdrewcommented, Aug 18, 2021

Hmm, okay that’s weird. I’ve created a bare-bones repo to demonstrate the bug - and it’s working there just fine. I’m going to have to dig in a little harder to figure out what’s causing it to break in my actual app.

0reactions
easybirdcommented, Oct 29, 2021

The issue is related to Hermes, and the way they handle regexes:

Solution:

  • Issue only occurs in debug mode.
  • In debug mode, disabling Hermes in your Podfile and rebuilding the app solves the issue
Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing Functions to Components - React
Pass event handlers and other functions as props to child components: ... You can use an arrow function to wrap around an event...
Read more >
How can I insert a line break into a <Text> component in ...
I want to insert a new line (like \r\n, <br />) in a Text component in React Native. If I have: <text> <br...
Read more >
React Fundamentals - React Native
To understand React Native fully, you need a solid foundation in React. This short introduction to React can help you get started or...
Read more >
Troubleshooting | React Navigation
This can happen if you are passing non-serializable values such as class instances, functions etc. in params. React Navigation warns you in this...
Read more >
Render a String with Non-breaking Spaces in React | Pluralsight
Import the useState hook from React to use state inside a functional component. Keep a state for storing the string entered by 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