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.

`getInitializationEntries` contents causes incorrect `Error` position

See original GitHub issue

Environment

Both iOS and Android, with or without hermes.

Description

When throwing an error inside a repack app (including the TesterApp) the line + column combination is not matching the actual position in the bundle file, therefore the source map lookup ends up on the wrong file/line. The produced source map itself is correct and maps perfectly if getting the position by inspecting the bundle manually or running the bundle via node.

This seems to be caused by the import of react-native package somehow.

Reproducible Demo

Edit TesterApp/index.js to be:

throw new Error('Lol');

and remove ReactNative.getInitializationEntries spread from webpack.config.js and observe that the line+column thrown in RN are correct. Add back ReactNative.getInitializationEntries and see that it doesn’t match anymore.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
obladorcommented, Oct 26, 2021

OK, it needs some more verification on our repo, but I managed to get the TesterApp to work with these settings:

minimizer: [
  new TerserPlugin({
    test: /\.(js)?bundle(\?.*)?$/i,
    /**
     * Prevents emitting text file with comments, licenses etc.
     * If you want to gather in-file licenses, feel free to remove this line or configure it
     * differently.
     */
    extractComments: false,
    terserOptions: {
      format: {
        comments: false,
      },
    },
  }),
],
0reactions
TMaszkocommented, Feb 3, 2022

Hi, after throughout investigation we know that: without any changes to the webpack config we’ve got following results:

  • dev=true,minify=false -> correct stack trace
  • dev=true,minify=true -> incorrect stack trace
  • dev=false, minify=true -> incorrect stack trace

with suggested changes (disabling any comments):

  • dev=true, minify=false -> correct stack trace
  • dev=true, minify=true -> correct stack trace (/*webpackChunkName*/) will be removed as well so just keep that in mind and be careful.
  • dev=false, minify=true -> correct stack trace

Turned out that comments that start with @license and ! like those generated by the webpack 😃 caused JSC to return wrong column number when Error was thrown. In the dev mode before our index file there is a different type of comment and probably that’s the reason why it works properly. Surprisingly on Hermes everything should work just fine!

Read more comments on GitHub >

github_iconTop Results From Across the Web

E4 Preference Initializer won´t get called - Stack Overflow
I´m using Eclipse 4.5.1 on a win7 x64 I googled a lot and found a lot of Threads concerning this, but I just...
Read more >
Detecting Positioning Errors and Estimating Correct ... - PLOS
The main problem addressed in this paper is the positioning error in such systems. All positioning systems have errors mainly caused by ...
Read more >
A Webpack-based toolkit to build your React Native ...
`getInitializationEntries` contents causes incorrect `Error` position ... is not matching the actual position in the bundle file, ...
Read more >
The repack from callstack - GithubHelp
`getInitializationEntries` contents causes incorrect `Error` position ... is not matching the actual position in the bundle file, ...
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