react-native-fabric-crashlytics: Can't interpret line numbers with sourcemap.

When I use this component, I get a log file in Crashlytics that looks something like this:

Non-fatal Exception: Can't find variable: foobar
0  ???                            0x0 onPress (main.jsbundle:9477)
1  ???                            0x0 _onPress (main.jsbundle:9125)
2  ???                            0x0 a (main.jsbundle:1653)
3  ???                            0x0 o (main.jsbundle:1605)

When I use sourcemap using the script given here, and using line number 9477 and column 1, I get this output:

{ source: null, line: null, column: null, name: null }

There are only 608 lines in my main.jsbundle. How to interpret the output I’m seeing on crashlytics?

Thanks

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 33 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@mikelambert When would merge the pr?

So I’m now after a full project setup with how I think this can work, and it works great. Building the sourcemap is done in a similar way to a bundle, so I guess this is a command a user would need to run (I hacked the default react-native runner - but I think we can drive the fact that the build will always generate source maps to the core react native repo with a PR, aside from little more CPU i don’t see why not)

So here’s how you engage with the new API:

function crashload(){
  const path = `${RNFS.MainBundlePath}/sourcemap.js`
  RNFS.readFile(path, 'utf8').then((contents)=>{
    crashlytics.init(JSON.parse(contents))
  })
}
crashload()

Unfortunately, anyone wanting to read a bundled source map has only one way to do that - with RNFS. Previous React Native releases had already read sourcemaps and had sourcemap exposed as a magic global variable but right now a React Native process comes up blank. It was made so in order to save memory - so we might need to warn users that using sourcemaps isn’t for free.

Back to the code sample, here, init takes sourcemap. This is adjusted to @mikelambert comment about using init with or without sourcemap, I haven’t yet did that - but we can make it not load and use sourcemap when the argument isn’t given.

sourcemap.js is built the same way main.jsbundle is built, and resides in the main app the same way for it to be packaged (and read later):

image

And to sum it up, this uses the patch to this library and the react-native-fabric fork with the fixed type conversion bug.

Next up I’m going to submit a PR tomorrow (since I need to use this time right now for something else), and that will include the init which knows how to toggle modes. With that, and the snippet above that we can put in the README.md, we have a working solution.

Hey guys, I’ve been working on this problem, and after pulling most of my hair out, finally have a solution. Sadly, I can now say that none of the above will really work, because there are a few fundamental bugs in how this library interprets positions, and how Crashlytics accepts data (might be on their side).

The fix is a combination of pulling sourcemaps, tweaking this library and the native crashlytics reporting as well. I need some time to pick up the pieces and make an elegant patch and for now, stay tuned 😃.