5

I want to read crashlytics reports from react-native app but it's not readable at all in firebase console. Example crash from Android looks like this:

Non-fatal Exception: io.invertase.firebase.crashlytics.UnhandledPromiseRejection
Invalid RegExp pattern: Parenthesized expression not closed
.RegExp ((native):0:0)
.anonymous (address at index.android.bundle:1:2065589)
.ue (address at index.android.bundle:1:2070284)
.ce (address at index.android.bundle:1:2069288)
.Be (address at index.android.bundle:1:2080135)

I have hermes enabled and my signed build apk generate index.android.bundle in precompiled format (build/generated/assets/react/appName/release/index.android.bundle) with source map file build/sourcemaps/react/appName/release/index.android.bundle.map. I tried to read those files using npm package source-map-explorer but unfortunately it always produce below error:

source-map-explorer index.android.bundle index.android.bundle.map 
index.android.bundle
  Your source map refers to generated column 165922 on line 1, but the source only contains 165920 column(s) on that line.
  Check that you are using the correct source map.
  1. Can i upload source-map to firebase in order to make errors readable in firebase console?
  2. How can i read hermes bundle file using sourcemap?
lukhol
  • 318
  • 2
  • 6
  • 18

1 Answers1

5

You just need to use

npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map < stacktrace.txt

put your stacktrace in stacktrack.txt. (remove the 0:0 for it to work)

for more information please go to https://reactnative.dev/docs/next/symbolication

Maxim Toyberman
  • 1,906
  • 1
  • 20
  • 35
  • 6
    I guess theres no way to make this automatically work in the Firebase console though? – twiz Jun 20 '21 at 11:33
  • Hello, I tried this and it creates a n empty stacktrace.txt. Thanks. – user2078023 Feb 08 '22 at 12:23
  • This command above converts a stacktrace from Firebase Crashlytics to a more readable one. You need to copy the stacktrace from Crashlytics, paste it on stacktrack.txt, run then run that metro-symbolicate command. – Roni Castro Jun 05 '23 at 15:26