bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
370 stars 121 forks source link

Sourcemap not getting applied with hermes and app bundles #449

Closed john1jan closed 4 years ago

john1jan commented 4 years ago

We are using

react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 bugsnag-react-nativ : v2.23.6

Sourcemap is not getting applied to the stack traces

We are using hermes engine and we have released the app using android app bundles

xljones commented 4 years ago

Hey @john1jan, we've received your message at support, and are investigating.

jlo1 commented 4 years ago

Hi @xander-jones ! Any update on this issue? This is pretty problematic for us.

Was trying the new commands in the Bugnsag docs, but noticed that android/app/build/generated/sourcemaps/react/release/index.android.bundle.map doesn't actually exist.

Seems sentry hit a similar issue, and had to adjust the sourcemap detection logic? https://github.com/getsentry/sentry-react-native/pull/777/files

mattdyoung commented 4 years ago

@jlo1 We're currently investigating this and hope to be able to provide an update soon. Thanks for the additional info.

mattdyoung commented 4 years ago

@jlo1 We've just completed some testing on an example app on React Native 0.61.5 using both Hermes and App Bundles, and we were able to successfully upload and apply source maps in Bugsnag by following our standard instructions for Hermes: https://docs.bugsnag.com/platforms/react-native/react-native/showing-full-stacktraces/#uploading-hermes-source-maps

You state that android/app/build/generated/sourcemaps/react/release/index.android.bundle.map doesn't exist, whereas in our testing the source map is output in that location by the gradle build when building the bundle:

./gradlew bundleRelease

I feel like we're missing some key piece of information to allow us to reproduce what you're seeing.

Are you able to share any more information about your build process / app structure or even better a reproduction example we could work with?

jlo1 commented 4 years ago

Thanks for the quick response @mattdyoung !

Ah, sorry for the confusion -- I was testing with our other build types on Android, using ./gradlew bundleAlpha and ./gradlew bundleBeta. Just confirmed that for bundleRelease, the sourcemaps do in fact get generated properly, and are properly linked in bugsnag.

Is there a way to reliably get the sourcemaps for other buildTypes? Just reproduced this on a fresh react-native project, adding in a new build type, and saw the same issue, where the intermediates/sourcemaps folder is populated, but generated/sourcemaps is not.

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }

        alpha {
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }

        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
jlo1 commented 4 years ago

Confirmed it's a limitation with react-native and how they support hermesFlags. Currently there is no support for hermesFlags${buildType}, and they by default only upload source maps for release: https://github.com/facebook/react-native/blob/0.61-stable/react.gradle#L157

If I set hermesFlagsDebug to true, can see the other sourcemaps get generated in expected directories.

Thanks for the help and sorry about the false alarm!

mattdyoung commented 4 years ago

Thanks for the info, and glad you were able to find a way forward!