getsentry / sentry-react-native

Official Sentry SDK for React-Native

Home Page:https://sentry.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source code was not found 1.3.0 (iOS & Android)

valeriashpiner opened this issue · comments

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native
  • react-native-sentry

react-native version: 0.61.2
SDK version: 1.3.0

Init Code:

Sentry.init({
  dsn: 'https://...@sentry.io/...'
});

I have the following issue:

After update today from 1.2.2 to 1.3.0 with Hermes support, I ran iOS build in release mode and added following line to create crash:

throw new Error ('New Sentry!')

I ran assembleRelease for android and then regular build with the error.

Steps to reproduce:

  1. yarn add @sentry/react-native@latest
  2. pod install (it updated sentry/react-native to 1.3.0)
  3. watchman watch-del-all && rm -f yarn.lock && rm -rf node_modules && yarn && yarn start --reset-cache

Actual result:
I don't see sourcemaps for iOS anymore.
Screen Shot 2020-02-12 at 9 49 29 AM
Screen Shot 2020-02-12 at 9 49 21 AM

I don't see sourcemaps for android, but 1.3.0 sees Hermes engine.
Screen Shot 2020-02-12 at 9 58 34 AM

Expected result:
I would like to be able to see the source of error for ios and android.

Thank you!

I fixed iOS by uploading source maps manually 😞
It didn't upload for me in the usual way (release mode through XCode).
For android, I still don't see the source maps even after I upload it manually.

Same issue.
Hmm, rollback to 1.2.2 not helped.

There is a small bug in iOS right now, we are working on a fix.
It sets the wrong release name by default.

thank you @HazAT! Is android suppose to work? I pushed source maps manually and I see them in artifacts, but I still not see them in error (Source maps wasn’t found).

@valeriashpiner Can you post a link to an event so I can take a look?
If built in release it should work.
In debug you also should see the code but we have a small bug on the server saying "Source Code not found" but actually the frame is symbolicated correctly.

@HazAT I think I found android issue! My artifacts and files which Sentry looks for have different names! 😄
I don’t know why they don’t upload through assembleRelease, but I will upload them manually and check.

Thank you for iOS quick fix! ❤️

62508D8F-27DD-44C6-8608-07F83BF9592C
6DF55ABF-3E50-4CD1-B6A4-8663A7A584CE

Yes, we changed how releases are named, by default sentry-cli should create the new matching releases correctly. Do you invoke sentry-cli manually?

@HazAT Yes, I made it like this:

react-native bundle \ --dev false \ --platform android \ --entry-file index.js \ --bundle-output index.android.bundle \ --sourcemap-output index.android.bundle.map

and then this:

node_modules/@sentry/cli/bin/sentry-cli --auth-token **[token]** releases --org **[org name]** --project android-app files **[release name]** upload-sourcemaps --dist 3123 --strip-prefix index.js --rewrite index.android.bundle.map index.android.bundle

so far I see bundles in artifacts and Sentry doesn't complain anymore.
as soon as we will receive crash in release mode from users, I will know does it work correctly or not.

1.3.1 has been released, fixing the iOS issue.

@HazAT:

I made a build in Release mode. iOS.
Artifacts did not upload.
Screen Shot 2020-02-13 at 11 28 42 AM

The error shows in the correct line, but the text is wrong.
I create an error with text Valeria yesterday, today it's `This is error!:
✔️ source maps show me old text
✔️ BUT in exception, it's correct text.

Even when I uploaded source maps manually, I still see old text in error.
Screen Shot 2020-02-13 at 11 28 23 AM
Screen Shot 2020-02-13 at 11 28 28 AM

Android with source maps - manual upload (1.3.1):
Screen Shot 2020-02-13 at 1 01 58 PM
Screen Shot 2020-02-13 at 1 02 07 PM

@valeriashpiner the same is happening to us when enabling Hermes, using the JSC on android show the correct line number and source code. We create and upload our sourcemaps manually

@christianbach this release (1.3.0) supposed to fix Hermes issue. I don’t understand why it’s still not working and also iOS source maps are incorrect.

@valeriashpiner for us it works as expected on iOS. We are only seeing this issue on Android with Hermes

@christianbach same for me, can't get sourcemaps on Android, iOS seems to be fine.

@denissb @christianbach could you, please, explain me how did you upload source maps for ios?
for example, my current app in release (for users) has 1.2.2 sentry version, but my beta app version already has - 1.3.1.

After upgrade I receive incorrect sours maps for both, but I uploaded source maps manually, I uploaded them through CI and also I uploaded sourse maps through release mode (it doesn’t uploaded for me in this case). I don’t understand what I do incorrect, because my steps the same as usual.

@HazAT I can share links for android and ios cases from sentry, if you need.

@valeriashpiner
The standard way described in the doc (and used by sentry-wizard on setup): https://docs.sentry.io/platforms/react-native/manual-setup/#upload-debug-symbols-to-sentry

In xcode Build Phases I have a script step that takes care of uploading
Upload Debug Symbols to Sentry

export SENTRY_PROPERTIES=sentry.properties
../node_modules/@sentry/cli/bin/sentry-cli upload-dif "$DWARF_DSYM_FOLDER_PATH"

@denissb yes, I also have all this. I even see my artifacts, it just shows me incorrects lines.

Please like Sentry issue here so I can take a look at your account.
Remember Release/Dist of the event needs to match the Release/Dist in the event otherwise, we can't match the sourcemap.

@HazAT

✔️ios (error from current prod): https://sentry.io/organizations/dynamite/issues/1513236688/?project=1327138&query=is%3Aunresolved

✔️android (error from beta build): https://sentry.io/organizations/dynamite/issues/1512988484/?project=1327140&query=is%3Aunresolved

seems that all source maps are connected, correct me if I am wrong. thank you for help!

We do everything manually using fastlane and sentry-fastlane-plugin. Everything works as expected on iOS and Android (using JSC). When we switch to using Hermes on Android source maps are lost...

@HazAT please, ignore my iOS issue.
Probably when I created main.jsbundle.map manually something was wrong with my entry file.

We have issue only with Android also.

@valeriashpiner I looked at your issues. I am not really sure what's happening on Android, it seems to be correct but the source map on the server isn't applied correctly. It seems to be a bug on the server because the bundle and source map look correctly.

Screen Shot 2020-02-17 at 15 18 43

Looks like hermes is not being handled correctly on 1.3.0 and 1.3.1

@lukebars Can you post a link to this issue on sentry.io?

@HazAT i'm experiencing the same problem. Here's a link to an issue of mine. I'm using "@sentry/react-native": "1.3.1". Hope this helps you find the issue (or maybe i'm just doing something wrong 😬).

@desmondmc You release doesn't contain any artifacts, make sure you invoke sentry-cli to upload the correct bundle and source map.
https://sentry.io/organizations/hevy/releases/com.hevy%401.16.9%2B286/artifacts/?project=1497815&query=release%3Acom.hevy%401.16.9%2B286

@HazAT looks like my android bundle file results as 0B size. Any ideas how to debug that?
image

issue url

Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.hidden.hidden@1.2.6+26 distribution 26
> Bundled 2 files for upload
> Uploaded release files to Sentry
> File upload complete

Source Map Upload Report
  Minified Scripts
    ~/index.android.bundle (sourcemap at index.android.bundle.map)
  Source Maps
    ~/index.android.bundle.map```

@HazAT Here's an error on Hermes using "@sentry/react-native": "1.3.1"
image

Artifacts seems correct:
image

Link to issue:
https://sentry.io/organizations/bonnier-news/issues/1510671450/?project=723762&sort=new

@christianbach Same as
#761 (comment)

we are tacking a look at what's going on.
Just to make sure, you don't have any special settings or anything configured right?
It's a release build?
Because the only thing they have in common is that both are "staging" releases.

Thanks for looking into this. The only special setting is the environment that is set to stage.

Works as expected on the "standard" JSC.

Here are the tags:
image

@christianbach What version of react-native are you running? What is really odd is that your uploaded bundle is not Hermes bytecode, instead, it's just minified javascript. We are in the process of trying to reproduce this.

Hmm, interesting. We are creating our bundle and source maps manually in fastlane usingreact-native bundle. Perhaps we are doing it wrong for Hermes...

We are running react-native 0.61.4

@christianbach this is most likely the issue.

Our current guess is you enabled Hermes:

  project.ext.react = [
     entryFile: "index.js",
     enableHermes: true  // clean and rebuild if changing
  ]

but you are actually building a JSC bundle always. Therefore we are confused if this is now a real Hermes bundle or not.

We will fix this on our side regardless @Swatinem is already on it but you can try that as a workaround.

Hmm, interesting. We are creating our bundle and source maps manually in fastlane usingreact-native bundle. Perhaps we are doing it wrong for Hermes...

Can you elaborate on how you do it exactly?
I don’t quite know what is going on here, but I suspect that the source map that is uploaded to sentry does not match whatever is executed.

See https://github.com/getsentry/rust-sourcemap/tree/master/tests/fixtures/react-native-hermes for how to generate a correct source map. It actually is a 3-step process, which the react-native gradle job does for you. If you manually bundle, you have to replicate that to have the correct source map.

The hermes support that I built is rather a hack to make it work with the current way of doing things, rather than a clean re-architecture of the pipeline to better fit the usecase.
One of the implications of doing it this way is that correct hermes support right now shows a 0B "minified source", like @lukebars mentioned. This means that sentry-cli correctly detected a hermes bytecode file, which it then links to the sourcemap. The bytecode itself is thrown away, hence the 0B.

@christianbach @valeriashpiner
your stacktrace looks very much like bytecode offsets, but your uploaded source/sourcemap is for the minified js file (pre-hermes compilation), so there seems to be a mismatch.

@lukebars
the stacktrace you showed above has (address at in it, which is an indication that you have outdated versions of sentry packages. The latest updates of @sentry/{browser,react-native} should correctly strip that.

So pleas double check that you have all the latest dependency updates, and are uploading the correct sources via sentry-cli.

BUT, there still is a bug in our processor i think. It assumes that you always use Metro + Hermes, I think just using Metro without Hermes is actually broken right now. I’m looking into it.

Thanks @Swatinem and @HazAT, i took a closer look how we generate out current sourcemaps. And your guess is correct we only use react-native bundle and never call hermes-engine.

Our new implementation will look something like this:

react-native bundle \ --platform android \ --dev false \ --entry-file index.js \ --bundle-output android-release.bundle \ --sourcemap-output android-release.bundle.map \ --sourcemap-sources-root ./

node_modules/hermes-engine/osx-bin/hermes -emit-binary \ -out android-release.bundle.hbc android-release.bundle -output-source-map

We are using the sentry_upload_sourcemap from fastlane-plugin-sentry will it pick up the hermes bytecode file automatically if it resides in the same folder as the sourcemap and bundle file?

We are still seeing the same issue when generating source maps with hemes.

image

Artifacts:
image

Link to issue: https://sentry.io/organizations/bonnier-news/issues/1510671450/?project=723762&sort=new

Still doesn’t look too good.

The link I posted above looks like this:

    $ npx react-native bundle --platform android --entry-file input.js --bundle-output intermediate.js --sourcemap-output intermediate.js.map
    $ hermes -O -emit-binary -output-source-map -out=intermediate2 intermediate.js
    $ node react-native/scripts/compose-source-maps.js intermediate.js.map intermediate2.map -o output.map

You are missing the third step to combine the two intermediate sourcemaps? If you then provide the resulting binary bytecode and combined sourcemap to sentry-cli, that should upload the correct things and result in a 0B file, as mentioned above.

@Swatinem I will try these commands with my source maps for android now.

@Swatinem so i kind of got it working. We now get source maps when using Hermes, but sadly there seems to be a missmatch with the line numbers.
image

image

Link to issue:
https://sentry.io/organizations/bonnier-news/issues/1520420652/?project=723762&sort=new

@christianbach
Navigating to your artifacts from the linked issue: https://sentry.io/organizations/bonnier-news/issues/1520420652/?project=723762&sort=new
I still see that the "minified source" is js. You should pass the hermes bytecode to sentry-cli, which will then just upload a 0-byte file. Still trying to wrap my head around how the serverside processing behaves when you don’t have the correct artifacts uploaded.

@Swatinem thanks for your help. I managed to solve the problem by skipping our own bundling and using the bundle and source maps from react-native.

@christianbach could you advise, please, what commands did you use to make correct android bundles?

@Swatinem when I do hermes -O -emit-binary ... to create my bundles with Hermes I received bash: hermes: command not found :( Is it possible to install hermes globally or how to fix it?

I'm still having the same issue with 1.3.2 (and 1.3.3) when building with ./gradlew assembleRelease
Running Sentry Wizard... version: 1.1.1 | sentry-cli version: 1.51.1

project.ext.react = [ entryFile: "index.js", enableHermes: true, ]

link
shared link

image

image
yarn.lock

 "@sentry/cli@^1.51.0":
  "@sentry/core@5.12.4", "@sentry/core@^5.12.0":
  "@sentry/hub@5.12.4":
  "@sentry/integrations@^5.12.0":
  "@sentry/minimal@5.12.4":
  "@sentry/react-native@^1.3.2":
  "@sentry/types@5.12.4", "@sentry/types@^5.12.0":
  "@sentry/utils@5.12.4", "@sentry/utils@^5.12.0":
  "@sentry/wizard@^1.1.1":

@Swatinem @HazAT any ideas?

@Swatinem when I do hermes -O -emit-binary ... to create my bundles with Hermes I received bash: hermes: command not found :( Is it possible to install hermes globally or how to fix it?

@valeriashpiner its not in your path I guess?

It is usually in node_modules/hermes-engine/linux64-bin/hermes or a different directory, depending on your OS.

We are facing issues with Sentry on Android with v8, without enabling Hermes.

I can confirm that the bundles are uploaded:
image

But the issue says that source code was not found:
image
image

Any idea how to solve this?

@altany have you tried to rewrite frames? e.g.

import { RewriteFrames } from '@sentry/integrations';

const rewriteFramesIntegration = new RewriteFrames({
  iteratee: frame => {
    if (frame.filename) {
      frame.filename = frame.filename
        .replace(/^file\:\/\//, '')
        .replace(/^address at /, '')
        .replace(/^.*\/[^\.]+(\.app|CodePush|.*(?=\/))/, '')
        .replace(/^at /, '');

      const appPrefix = 'app://';
      // We always want to have a tripple slash
      frame.filename =
        frame.filename.indexOf('/') === 0
          ? `${appPrefix}${frame.filename}`
          : `${appPrefix}/${frame.filename}`;
    }
    return frame;
  },
});

    Sentry.init({
      dsn: config.SENTRY_DSN,
      integrations: [rewriteFramesIntegration],
    });
   
};

@lukebars Thanks for your suggestion. I will test it and let you know if it works.
Just to clarify, is this a one-off thing or it needs to be committed?

@altany did you fix it?
I see sourcemaps for ios and android in artifacts, but also receive Source code was not found in details.

I have no clue what's going on with our Sentry.
We updated to 1.3.3.

IOS and Android don't receive sourcemaps automatically through cli.
Cli commands:
Screen Shot 2020-03-13 at 4 02 18 PM
Screen Shot 2020-03-13 at 4 02 23 PM

When I generated locally and push to Sentry, I see them in artifacts, but also I see that:
Screen Shot 2020-03-13 at 4 00 02 PM

For android, we use v8 now.

@Swatinem @HazAT feel free to check: https://sentry.io/share/issue/e864e4c711d742eb834ad5742046006b/

I don't understand why with the process which should be so easy, we struggle so much :(

I tried:

  • Version 1.3.1 and 1.3.3
  • Use RewriteFrames as shown above.
  • My Sentry.init calls on the top of App.js.
  • My init({ ... }).

Screen Shot 2020-03-13 at 4 05 06 PM

Please, let me know, maybe we can write to support to help us maintain Sentry properly because the current situation influenced our crash reports and we can't react fast.

@valeriashpiner the same issue @sentry/react-native 1.3.3 iOS
I have seen the source map at Artifacts , but the sentry server tell me 'source code was not found'

@valeriashpiner @lukebars rewriting frames did not seem to work. Same as others I still get this error.

Update: Upgrading to latest SDK 1.3.3 fixed the stacktrace and we stopped getting the above error about the missing source code.

We can finally see exactly which line failed and why.

I uploaded source maps through XCode and it also works for me (for ios). 1.3.3
Still fighting with android a bit :)

This could be the issue as described in #798 where only one version code (whatever version code happens to be processed last) gets a release. I've posted a workaround that creates a release for every version code here: #798 (comment)

Any solution on Android? I have @sentry/react-native 1.3.7 version and still
Zrzut ekranu 2020-05-8 o 09 41 44

and artifacts
Zrzut ekranu 2020-05-8 o 09 42 43

Hi @HazAT , we have an issue with the ios Source map.
Screenshot 2020-05-14 at 09 34 49

We have followed the doc to integrate sentry, version 1.3.8
But we cannot see our artifacts.

our configuration is this:
Sentry.init({
dsn: Config.SENTRY_KEY,
environment: Config.ENV,
release: packageJson.version + '+' + BUILD_NUMBER,
});

Could you support throw this issue?

On android we have fixed using this sentry.gradle:
https://github.com/azundo/sentry-react-native/blob/8068c61c95074ff7f4393a4a4ec52d8196f7dfa9/sentry.gradle

Even tho sentry-cli releases files --help does not show these params, I somehow managed to find it in the docs
--bundle path/to/bundle
--bundle-sourcemap path/to/source.map

This takes care of bundle formats, strips path prefix, etc 🙏

yarn run sentry-cli releases files com.company.project.qa@0.0.1+120 \
  upload-sourcemaps \
  --bundle android/app/build/generated/assets/react/release/index.android.bundle \
  --bundle-sourcemap android/app/build/generated/sourcemaps/react/release/index.android.bundle.map

Release name: <application id>@<version description>+<build number>
Ex: com.company.project.qa@0.0.1+120

EDIT
My bad, the options are correctly listed here

$ sentry-cli releases files upload-sourcemaps --help
sentry-cli-releases-files-upload-sourcemaps
Upload sourcemaps for a release.

USAGE:
    sentry-cli releases files <VERSION> upload-sourcemaps [OPTIONS] <PATHS>...

OPTIONS:
        --bundle <BUNDLE>
            Path to the application bundle (indexed, file, or regular)

        --bundle-sourcemap <BUNDLE_SOURCEMAP>    Path to the bundle sourcemap
commented

Hi @irekrog Have you resolved the issue with 0B index.android.bundle ?
I have the same

@v-anton it's expected behaviour with hermes engine on.

Make sure your ~/index.android.bundle.map is there and doesn't equal to 0B.

For me, I was using custom release and dist parameters with the CLI and init command. Like this:

npx sentry-cli \
    --auth-token $sentry_token \
    releases \
    --org my-org \
    --project my-project \
    files "$bundle_id-$version" \
    upload-sourcemaps ./sourcemaps \
    --dist $iosVersion \

and

    Sentry.init({
      environment:  'production' ,
      dsn: 'https://asdf@asdf.ingest.sentry.io/asdf', integrations: [
        new Sentry.ReactNativeTracing({
          routingInstrumentation,
          release: `${getBundleId()}-${pkg.version}`,
          dist: `${getBuildNumber()}`,
        }),
      ],
    });

I noticed that in the source maps, however, that despite having set the release and dist, it was actually uploading a source map called with a release string of $bundle_id@$version+$iosVersion, and looking for that, so I changed it to:

npx sentry-cli \
    --auth-token $sentry_token \
    releases \
    --org my-org \
    --project my-project \
    files "$bundle_id@$version+$iosVersion" \ # <-- this changed
    upload-sourcemaps ./sourcemaps \
    --dist $iosVersion \

and

    Sentry.init({
      environment:  'production' ,
      dsn: 'https://asdf@asdf.ingest.sentry.io/asdf', integrations: [
        new Sentry.ReactNativeTracing({
          routingInstrumentation,
          release: `${getBundleId()}@${pkg.version}+${getBuildNumber()}`, // <-- different
          dist: `${getBuildNumber()}`,
        }),
      ],
    });

And now it works! So it seems like some parameters in Sentry are just not working, whether it's the CLI or the SDK, not sure.

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

does that still happen using the latest Sentry RN version? just tried and it works ootb

@marandaneto Source maps get uploaded just fine for me now on both Android and iOS. Running hermes for both iOS and Android on react-native: "0.66.1" and @sentry/react-native": "3.1.1"
I believe it got fixed in version @sentry/react-native": "2.5.0 but don't trust my word on this one.