Metro: Wrong source map is generated

Created on 8 Mar 2018  路  13Comments  路  Source: facebook/metro

We came from this discussion on react-native repo where @hramos recommend us to move the issue here: https://github.com/facebook/react-native/issues/6946

You can find all the detailed information in there. Tho, to summarize: the packager generates the sourcemap with wrong lines more times that I'd like to recon.

Problem is still raising in latests versions. Thank you :)

Most helpful comment

@rafeca and @sospedra Here is a simple test repository to reproduce the issue along with the steps i have followed.
https://github.com/anandprabhu/HelloRN

All 13 comments

I can confirm, tried it with the latest version and the error is still in there.
I am not really sure though I have a repro case locally but haven't had enough time to dive through the whole codebase to create a minimal independent repro case. (The one I have right now requires way to much setup).

I suspect the issue lies somewhere when metro is stitching together all sources/sources maps that come from uglify.

Thanks for reporting! A minimal repro scenario would indeed help us a lot reproducing and fixing the issue

For a long time....
But the problem is always there..

@rafeca and @sospedra Here is a simple test repository to reproduce the issue along with the steps i have followed.
https://github.com/anandprabhu/HelloRN

Thanks @anandprabhu! I'm currently on PTO, I'll take a look at this next week when I'm back to the office

Hey @anandprabhu , I've spent some time debugging the issue. First of all, thanks for the test repository and the repro instructions, it makes it so much easier to debug these kind of issues 馃憤

After reproducing it, I think that the issue comes from React Native itself (not sure if it's from some native layer of from the JS interpreter).

What makes me think that is that the first line that gets reported by pidcat is already wrong (before even being symbolicated using the sourcemaps):

onPress@303:987
...

To check that, you can open the actual minified bundle from android/app/build/intermediates/assets/release/index.android.bundle and go to line 303, column 987 and you'll see that it does not point indeed to the place where the error is thrown.

From this point, metro sourcemaps are working fine, since they translate that position to its corresponding source position.

I think that with this additional information, the discussion can be moved back to https://github.com/facebook/react-native/issues/6946

Closing this issue

Just found out that this issue is actually caused by metro! sorry about that, a fix is coming really soon 馃槂

And updates on this? I'm having trouble with sourcemap lines being all over the place, unable to set breakpoints, without using 'debugger', etc.

@jshearer the fix was released with metro v0.37.2, and should be available on RN 0.56.0

@rafeca I am using RN 0.55.4. Is it possible to use the version with that fix? Thanks!

Wohooo! 馃帄

Hi, im on react-native 0.57.1 The problem is still there, even debugger; statements makes chrome stop at a shifted place, it is impossible to debug as it is, there is some cache to clean?

Was this page helpful?
0 / 5 - 0 ratings