Sentry-react-native: Source code was not found for app:///main.jsbundle

Created on 24 Jan 2018  ·  23Comments  ·  Source: getsentry/sentry-react-native

OS:

  • [ ] Windows
  • [x] MacOS
  • [ ] Linux

_Platform:_

  • [x] iOS
  • [ ] Android

Output of node -v && npm -v && npm ls --prod --depth=0

v6.12.1
3.10.10
[email protected] /Users/dengwanc/Projects/maimai_react_native
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Config:

Sentry.config("http://user:[email protected]//18", {
    release: '2da95dfb052f477380608d59d32b4ab9',
}).install();

I have following issue:

react native sentry source map JUST not working !!!

my upload script

sentry-cli --auth-token 27d37b4efd73439d820fgcdzaowanmiewang1f84ed1949148137c3fb9a3 \
--url http://some-sentry.com \
releases -o sentry -p react-native files \
2da95dfb052f477380kk8d59d32b4ab9 upload-sourcemaps \
--rewrite --validate main.jsbundle.map

I GOT THIS IN Senry UI ,I am SO confused NOW

Source code was not found for app:///main.jsbundle 
{
  "url": "app:///main.jsbundle"
}

Most helpful comment

I followed the instructions carefully (including the code push part):
https://docs.sentry.io/clients/react-native/

And I still can't get the line numbers and source code to be shown at the dashboard. I get this error:

Source code was not found for app:///index.bundle

It looks like Sentry is looking for index.bundle, while the artifacts in the release (which was created by Sentry Cli with code push command) looks like this:

~/main.jsbundle
~/main.jsbundle.map

All 23 comments

I guess you have to add --url-prefix ~/ as an additional parameter.
Can you share a screenshot of your release artifacts in Sentry?

This is My release list

app:/main.jsbundle.map
None
3.8 MB

file:/main.jsbundle
None
1.0 MB

file:/main.jsbundle.map
None
3.8 MB

https://dengwanc.github.io/main.jsbundle
None
1.0 MB

https://dengwanc.github.io/main.jsbundle.map
None
3.8 MB

~/main.jsbundle
None
1.0 MB

~/main.jsbundle.map
None
3.8 MB

Sorry Cant use Github Image Service IN China 😄

@dengwanc
A few things I've noticed.
First, it says reported with raven-js as SDK instead of react-native-sentry which indicates that something with your initial setup went wrong.
Did you call react-native link react-native-sentry?
Also, how are you building your app, in debug or release? Because the stacktrace looks more than strange, almost if you used not the facebook bundler.

react-native how to specify ios and android dir. like

react-native link react-native-sentry --native-dir my_ios_dir my_android_dir

I followed the instructions carefully (including the code push part):
https://docs.sentry.io/clients/react-native/

And I still can't get the line numbers and source code to be shown at the dashboard. I get this error:

Source code was not found for app:///index.bundle

It looks like Sentry is looking for index.bundle, while the artifacts in the release (which was created by Sentry Cli with code push command) looks like this:

~/main.jsbundle
~/main.jsbundle.map

@yaronlevi Can you link an event here?
The version and dist of the release in Sentry must match the version and dist on the event itself.
But in general this looks correct, would need to link to give a better answer.

@HazAT I'm facing a similar error when creating Android release builds. The ~/index.android.bundle and the ~/index.android.bundle.map are present in the Artifacts tab of Releases. But still for the javascript errors it shows Source code was not found for app://index.android.bundle. I am using the online hosted version of Sentry.

If your android event it reported with raven-js
This is not correct, this indicates something went wrong with the native Android SDK setup.

Here is probably the fix for your problem:
https://github.com/getsentry/react-native-sentry/issues/167
https://github.com/getsentry/react-native-sentry/issues/213

What version of Android Studio and build tools are you running?
I still need a way to reproduce this issue.

Make sure the event is reported with sentry-react-native
you can find this on the bottom of the event in the SDK section.

@HazAT I have configure the react-native-sentry library for both the iOS and Android builds. I am not sure why the SDK is mentioned as raven-js in the dashboard. Below are the details of the libs used,

"react": "^16.2.0",
"react-native": "^0.52.2",
"react-native-sentry": "^0.33.0"

I am using the command line to build the app and not using the Android Studio. Although the version i have currently installed is Android Studio 3.0 and the Build Tools is 26.0.0. Do let me know if you need more information which i could provide over e-mail directly.

@anandprabhu Can you look at the 2 issues I posted.
It looks like that compile project(':react-native-sentry') is missing in build.gradle.
The Android SDK is definitely not running and that's why it states raven-js.

@HazAT I have gone through both the issues but i do not find any issues with the build.gradle for my app. It seems to contain the correct entry for the compile project(':react-native-sentry') and creating build also works fine without any issues. I have tried to unlink the library, remove the node_modules folder and then do everything from the start. Still facing the same issues.

@anandprabhu
Can you do the following:
Create a clean react-native project and see if you still having this issue.

react-native init AwesomeProject
cd AwesomeProject
yarn add react-native-sentry
react-native link react-native-sentry
react-native run-android

I just did it and it worked.
Check the log output if you can find something like

...
io.sentry.android.AndroidSentryClientFactory: Sentry init with ctx='com.awesomeproject.MainApplication@95354ef' and dsn='Dsn{uri=https://sentry.io/}'
...
react-native-sentry: startWithDsnString 'YOUR DSN'

@HazAT I tried the same steps but do not find the lines that you have mentioned at the end. Will it be printout out in the command-line during the react-native run-android?

If it is running on a device you have to start logcat to see the output.
Alternatively, you can start the project in Android Studio.

@HazAT Could if be that our project is mainly created in Typescript and then transpiled into JavaScript code. But we are able to see that the bundle file is being created from the JavaScript source only and uploaded correctly in Sentry. But really not sure why the dashboard mentions raven-js in the SDK.

I am able to see the above mentioned entries in the new project created using the steps you had mentioned. But the same is not available in our application using the same libraries. Could it be because of the increment to the compileSdkVersion 26 and buildToolsVersion '26.0.0' ?

It could be the compileSdkVersion 26 and buildToolsVersion '26.0.0' I am not really sure.
The only thing I can say is that sentry-android is not running in your project, I have to take a look at your project to debug it otherwise you can only try to make Sentry run in your project.
The issue you are having cannot be Typescript, when your event is sent with sentry-react-native the stack trace will be fixed since we sentry-android makes sure that we add the necessary release information to the event.

@HazAT Ok fine let me try downgrading the version of the Android SDK and Build Tools and check if it works and update you.

@HazAT Downgrading the compileSdkVersion 26 and buildToolsVersion '26.0.0' breaks other libraries like lottie-react-native and react-native-vector-icons. I am unable to trigger a build from the command like or Android Studio. However if i increase the version directly in the Sentry SDK using Android Studio to 26 i am able to create the build but no information is present int he logcat.

@anandprabhu Sorry, with a reproducible case I can't do anything.
It must be something with your setup, all I can say is that the native android package isn't running in your project, why?
For that, I would need to see your project to help you debug it.

@anandprabhu Can you check if your MainApplication.java has these two lines:

...
import io.sentry.RNSentryPackage; // < --------------------
...
public class MainApplication extends Application implements ReactApplication {
    ...
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RNSentryPackage(MainApplication.this) // <------------------------------
      );
    }
    ...

@HazAT The MainApplication.java was missing the lines you had mentioned. Once i added the same it works fine now and able to see the mapping. But it seems to be showing it in a wrong line-number though. Since we are using TypeScript and convert them to JavaScript is there any way to map them to the lines in TypeScript source file ?

Also i guess we can update the Android SDK versions to the latest. Since i am trying with compileSdkVersion 26 and buildToolsVersion '26.0.2' it seems to working fine. Let me know if you want to test any other cases so that i could create a PR for the same.

@anandprabhu Your uploaded source map should do this correctly.
Keep in mind, old events will not get symbolicated only new ones.
Release and Dist have to match your artifacts.
Also, there is a bug in react-native itself facebook is aware of that line number may be wrong for android builds ref:
https://github.com/getsentry/react-native-sentry/issues/258
https://github.com/bugsnag/bugsnag-react-native/issues/142
https://github.com/facebook/react-native/issues/6946

I am closing this issue now since it's already hard to follow.
If anyone still having an issue with this, please consider creating a new issue with a reproducible case.
It seems like the issue is the linking process of react-native where it's not able to patch MainApplication.java.

@dengwanc i am also facing this issue brother not able to see the line number and only seeing this :
Source code was not found for app:///index.android.bundle Collapse
{
"url": "app:///index.android.bundle"
}

dont know what are the issues under lying.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThomasLarge picture ThomasLarge  ·  3Comments

brainbicycle picture brainbicycle  ·  3Comments

JonasBAJ picture JonasBAJ  ·  3Comments

poocart picture poocart  ·  3Comments

bneigher picture bneigher  ·  3Comments