sentry-react-native: Metro Bundler throws error on iOS: Unable to resolve module `./index.ios`.

With sentry-cli installed, on ios, the metro bundler tries to reach the bundle by expecting it to have a .ios extension, while for a lot of people, there is none.

Metro bundler logs:

"GET /index.ios.bundle?platform=ios&dev=true HTTP/1.1" 500 1835 "-" "sentry-cli/1.49.0"
Error: Unable to resolve module `./index.ios` from `/Users/user/project/.`: The module `./index.ios` could not be found from `/Users/user/project/.`. Indeed, none of these files exist:
  * `/Users/user/project/index.ios(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
  * `/Users/user/project/index.ios/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`

As you can see the command does : GET /index.ios.bundle while GET /index.bundle would be enough since .native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx would be tried.

This call may be based on node_modules/@sentry/react-native/ios/Sentry/Tests/Resources/ReactNative.json which contains those kind of lines:

...
{
   "lineNumber": 12,
   "file": "http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false",
   "methodName": "value",
   "column": 939
},
...

It may also be related to this file which contains lots of index.ios

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 16 (8 by maintainers)

Most upvoted comments

@lwmouneyrac I took the time now to try it with ignite.

Here is what I did:

  1. Installed ignite
  2. ignite new igniteapp
  3. cd igniteapp
  4. yarn add @sentry/react-native
  5. yarn sentry-wizard -i reactNative -p ios android
  6. Added to index.js
import * as Sentry from "@sentry/react-native"

Sentry.init({
  dsn: 'DSN'
})
  1. Added to demo-screen.tsx
<Text style={LOVE} text="Made with" onPress={() => {
  throw new Error("ignite test")
}}/>
  1. Open ios/igniteapp.xcworkspace

  2. Build the app in release mode image

  3. Stop Xcode, Start the app new and click on the button to crash the app, the next screenshot shows the result.

image

This looks correct, everything is working as expected and the stack trace is fine. I am really not sure what the problem is.

PS: I tried to run the app in debug mode and was able to get the same result as you did.

image

After a bit of debugging I found the issue, this is the PR fixing it: https://github.com/getsentry/sentry-react-native/pull/806

Now it also works in debug image

I am closing this issue, will release 1.3.4 today.

PPS: Please ignore the error on the issue detail page, this will be fixed on the server so it’s not shown. As long as the stacktrace is correct this is not an issue.