getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.56k stars 331 forks source link

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

Closed Alqasrawi closed 6 years ago

Alqasrawi commented 6 years ago

OS:

Platform:

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

v6.11.3
3.10.10
MyNamshiReactNativeApp@0.0.1 /Users/khaledalqasrawi/Development/namshi-android
├── glamorous-native@1.2.0
├── json-beautify@1.0.1
├── lodash-es@4.17.4
├── moment@2.19.3
├── prop-types@15.6.0
├── query-string@5.0.1
├── UNMET PEER DEPENDENCY react@16.0.0-beta.5
├── react-native@0.49.3
├── react-native-collapsible@0.9.0
├── react-native-credit-card-input@0.4.1
├── react-native-i18n@2.0.8
├── react-native-keyboard-aware-scroll-view@0.4.1
├── react-native-material-dropdown@0.8.0
├── react-native-material-textfield@0.10.2
├── react-native-modal@4.1.1
├── react-native-sentry@0.35.2
├── react-native-simple-radio-button@2.7.0
├── react-native-vector-icons@4.4.2
└── react-navigation@1.0.0-beta.13

Config:

Sentry.config(
'🔑',
      { logLevel: SentryLog.Verbose },
    ).install();

I have following issue: I get the "Source code was not found for app:///index.bundle" error on sentry.io dashboard

I added sentry to my react native app inside an existing Android app, I used the react-native link react-native-sentry command to integrate sentry in the project and I added:

apply from: "../../node_modules/react-native-sentry/sentry.gradle"

to app/build.gradle

The map file isn't uploaded to sentry and therefore the code is not reported with the crashes, only the stack trace.

Steps to reproduce:

Actual result:

Expected result:

sentry-probot[bot] commented 6 years ago

Hi there, I just edited this for you. Try not to post your DSN on GitHub.

Alqasrawi commented 6 years ago

Should I upload the bundle and the source map manually to sentry ? is there any other information I should provide with the ticket ?

I tried uploading the bundle and the source map manually and I got a "Invalid token (401)" error

Command used to generate the bundle and the source map:

react-native bundle --platform android --entry-file index.js --bundle-output <path-to-assets>/index.bundle --sourcemap-output <path-to-assets>/index.bundle.map --assets-dest <path-to-resources> --dev false

Command used to upload the bundle and the source map to sentry:

./node_modules/.bin/sentry-cli --auth-token <auth-token> --url http://sentry.mm.taou.com releases -o <organization-name> -p <project-name> files 6.7 upload-sourcemaps --rewrite --validate <path-to-assets>/index.bundle <path-to-assets>/index.bundle.map --strip-prefix <path-to-assets>/
HazAT commented 6 years ago

Hey, so it seems like you are using the wrong Auth Token. This is not your DSN, did you call react-native link react-native-sentry? This command should start the wizard and help you with the setup. You can find your auth token here: https://sentry.io/settings/account/api/auth-tokens/

Alqasrawi commented 6 years ago

Thanks for the reply, I managed to execute the upload command with the correct information, the files are uploaded now to sentry.io but I still get this error on sentry:

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

the build artifacts names are the following:

~/index.bundle
~/index.bundle.map
HazAT commented 6 years ago

Can you link an event here so I can take a look at it?

Alqasrawi commented 6 years ago

As mentioned in Issue 338 I forgot to add the RNSentryPackage:

reactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getActivity().getApplication())
                .addPackage(new MainReactPackage())
                .addPackage(new RNSentryPackage(null))
                .......
                .build();

P.S: I am integrating react native in an existing Android app, the react instance is managed inside a fragment, I didn't need to implement ReactApplication anywhere, I checked the source code for RNSentryPackage and the ReactApplication constructor argument is never used in the code. that's why I used null in the constructor.

vivek-walecha-657-zz commented 6 years ago

@Alqasrawi are you able to get the line number on sentry. I need a serious help on this, but no one on the forums helping. Even the sentry people are not helping 👎

HazAT commented 6 years ago

@vivek-walecha-657 Hey, no reason to be upset, I see your comment for the first time :) What command are you running to upload the source maps? This error indicates that they are not uploaded? Which version of react-native-sentry are you running? Can you link me to one of your issues so I can take a look in your account?

mattslight commented 5 years ago

org = sharek project = react-native architecture = ios

@HazAT I have successfully generated sourcemaps via:-

react-native bundle --platform ios --entry-file index.js --dev true --bundle-output ./index.bundle --assets-dest ./dist/sourcemap.js

And then uploaded the generated sourcemap.js to sentry (this works)

sentry-cli releases files BUILDNAME upload-sourcemaps ./dist/ --dist BUILDNUMBER --strip-prefix ABSOLUTE_PATH_TO/index.js --no-rewrite

But still in the sentry console it tells me via sentry web portal Source code was not found for app:///index.bundle.

What am I doing wrong please?

EDIT I am using codePush so I am now following the instructions for that: https://docs.sentry.io/clients/react-native/codepush/

I am still seeing the error Source code was not found for app:///index.bundle.

I have now set up the codePush metadata hook as per

codePush.getUpdateMetadata().then(update => {
  if (update) {
    Sentry.setVersion(update.appVersion + '-codepush:' + update.label)
  }
})

and

The following command is successful:-

sentry-cli react-native appcenter APPCENTER_ID ios ./build/codePush

> Fetching latest AppCenter deployment info
> Processing react-native AppCenter sourcemaps
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
> Uploading source maps for release com.fake_domain.FakeApp.ios-0.23-codepush:v59

Source Map Upload Report
  Minified Scripts
    ~/main.jsbundle (sourcemap at main.jsbundle.map)
  Source Maps
rdewolff commented 5 years ago

For me, this https://github.com/getsentry/sentry-cli/issues/233 helped, as the path I was using was just ./build and the correct one to use was ./build/codePush.