sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Source maps not being uploaded when hermes setting enabled

Open rafael-fecha opened this issue 3 years ago • 9 comments

Environment

"react-native": "0.67.4"
"@sentry/react-native": "3.4.0"

build.gradle

project.ext.react = [
    enableHermes: true, 
    bundleInBeta: true,
    devDisabledInBeta: true,
    bundleInProd: true,
    devDisabledInProd: true,
    bundleInDemo: true,
    devDisabledInDemo: true
]

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

Expected Result

Should upload correctly the source maps having hermes setting enabled

Actual Result

Sentry upload source maps fails.

Processing react-native sourcemaps for Sentry upload.
index.android.bundle.map - error: No such file or directory (os error 2)

I checked on the folder and it is only there index.android.bundle.packager.map and not index.android.bundle.map as expected. Probably the compile to bytecode using hermes step and the merge of the two source maps using compose-source-maps to get the final source map didn't happen.

According to the docs: If you do not need custom sourcemaps, the sentry.gradle build step fully supports Hermes source maps.

All works fine if I disable hermes.

Can you help me with this ?

rafael-fecha avatar Apr 04 '22 14:04 rafael-fecha

@rafael-fecha can you provide a minimal reproducible example? just tried and everything worked out.

marandaneto avatar Apr 04 '22 15:04 marandaneto

@rafael-fecha can you provide a minimal reproducible example? just tried and everything worked out.

@marandaneto hard to setup as it is a private repo. I forgot to mention that I'm using productFlavors when building the app, did you try it out with that as well ?

rafael-fecha avatar Apr 04 '22 15:04 rafael-fecha

@rafael-fecha minimal reproducible example could be as simple as an RN template only with sentry, so I can build and reproduce the issue. No, I've not tried to reproduce it with flavors.

marandaneto avatar Apr 04 '22 16:04 marandaneto

@rafael-fecha what's the command you are calling to build all the flavors?

marandaneto avatar Apr 04 '22 16:04 marandaneto

@rafael-fecha what's the command you are calling to build all the flavors?

Just with the standard e.g ./gradlew assembleBetaRelease or selecting variant and build on android studio, which will have the same behavior.

Bellow you can check some logs from the gradle task.

info Writing bundle output to: *MASKED_PATH*/android/app/build/generated/assets/react/beta/release/index.android.bundle
info Writing sourcemap output to: *MASKED_PATH*/android/app/build/intermediates/sourcemaps/react/beta/release/index.android.bundle.packager.map
  INFO    2022-04-04 20:18:39.154299 +02:00 sentry-cli was invoked with the following command line: "*MASKED_PATH*/node_modules/@sentry/cli/sentry-cli" "--log-level" "debug" "react-native" "gradle" "--bundle" "*MASKED_PATH*/android/app/build/generated/assets/react/beta/release/index.android.bundle" "--sourcemap" "*MASKED_PATH*/android/app/build/generated/sourcemaps/react/beta/release/index.android.bundle.map" "--release" 
INFO    2022-04-04 20:18:39.154646 +02:00   bundle path: *MASKED_PATH*/android/app/build/generated/assets/react/beta/release/index.android.bundle
INFO    2022-04-04 20:18:39.154650 +02:00   sourcemap path: *MASKED_PATH*/android/app/build/generated/sourcemaps/react/beta/release/index.android.bundle.map
error: No such file or directory (os error 2)
DEBUG   2022-04-04 20:18:39.163135 +02:00 skipping update nagger because session is not attended

rafael-fecha avatar Apr 04 '22 18:04 rafael-fecha

@rafael-fecha I've just tried here, upload worked fine and the event got symbolicated as well (with flavors), it must be something related to your pipeline or flavors configuration? please provide a minimal reproducible example.

marandaneto avatar Apr 05 '22 07:04 marandaneto

hey @marandaneto thanks for you help ! in the end the problem was that I was using hermesFlagsForVariant, when I removed this everything worked as expected. It looks like when defining hermesFlagsForVariant some code is not executed on react.gradle https://github.com/facebook/react-native/blob/main/react.gradle#L11

From my side, you can close the ticket, thanks again !

rafael-fecha avatar Apr 06 '22 12:04 rafael-fecha

Thanks for the feedback, I will check what's the issue with hermesFlagsForVariant

marandaneto avatar Apr 06 '22 13:04 marandaneto

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 🥀

github-actions[bot] avatar Apr 28 '22 00:04 github-actions[bot]

So I've tried this:

project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
    hermesFlagsForVariant: {
        def v -> !v.name.toLowerCase().contains('release') ? ['-w'] : []
    },
]

The uploading fails because the source map isn't generated and the file does not exist. The file root/android/app/build/generated/sourcemaps/react/release/index.android.bundle.map does not exist as it should so the CLI fails. So it's either your function (something is wrong) defined in the hermesFlagsForVariant which I didn't find proper documentation on how to use or it's a matter of implementing https://github.com/getsentry/sentry-react-native/issues/1660 which means we only try to upload the source maps for the variants that are configured.

I will close this since it's either not a bug in the SDK or a dupe of #1660

marandaneto avatar Oct 05 '22 13:10 marandaneto