question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't interpret line numbers with sourcemap.

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
toearthcommented, Dec 21, 2017

@mikelambert When would merge the pr?

3reactions
jondotcommented, Jul 10, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Overlay Shows Un-Source-Mapped Lines #226 - GitHub
But in my console I can see the correct (ie. source-mapped) line numbers: useAddFoo.js?fda8:23 Uncaught (in promise) TypeError: Cannot read property 'id' of ......
Read more >
How can I get the original line number and symbol from a ...
I'm logging javascript errors from my site, but the files are minimized so I don't get meaningful line numbers. I do have source...
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
This likely means that your source map doesn't contain or link to your original source files. Without your original source files, you're still ......
Read more >
Debugging JavaScript with Source Maps - Rollbar
Minified JavaScript code generates source maps that can help trace and debug problems back to the exact line of source code.
Read more >
Yet another explanation on sourcemap | by NGUYEN Trung
Some systems interpret special character differently (for example line ending character 10 ). Base64 was originally invented to solve these ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found