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.

Fix sourcemap support once and for all

See original GitHub issue

Problem:

  1. ganache-core requires source-map-support/register at top module scope.
  2. Loading source-map-support multiple times in different versions leads to broken source map support: https://github.com/evanw/node-source-map-support/issues/200
  3. This caused a lot of different issues in the Ethereum ecosystem:

Quick workaround:

source-map-support is able to ąvoid re-registering if one particular version is registered multiple times so a reasonable workaround is to force install only one particular version. To do this add in package.json:

"resolutions": {
    "source-map-support": "0.5.19"
  }

Real solution:

I see few solutions to this problem:

  1. Not to import source-map-support in this library at all. source-map-support was designed not to be included in other libraries. I believe that it should be importing in some kind of executors like ganache-cli

  2. Import it only when not in tests as celo did in their fork: https://github.com/celo-org/ganache-core/commit/3dbc32b214b3bb8f0dda2bfd909850a752a73a55 - I am not sure about this solution.

  3. Try to push a fix to source-map-support to detect multiple registers across different versions. Fix seems to be easy to create but the library doesn’t seem to be maintained anymore.

@gnidan I am linking past discussion with @sz-piotr: https://github.com/trufflesuite/truffle/issues/3432

Let me know how can I help to get this fixed.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
krzkaczorcommented, Mar 21, 2021

That’s perfect @davidmurdoch. Should I close this now or when it gets merged?

1reaction
davidmurdochcommented, Mar 21, 2021

The next version of ganache core will handle source-map-support properly (via # 1), and truffle will soon as well: https://github.com/trufflesuite/truffle/pull/3929

p.s., resolutions is a yarn-only feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the source-map-support.sourceMapSupport ... - Snyk
Source maps are completely general (not specific to any one language) so you can use source maps with multiple compile-to-JS languages in the...
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
4 Reasons Why Your Source Maps are Broken · Missing or incorrect source map directive · Missing original source files · Bad source...
Read more >
Is there source map support for typescript in node / nodemon?
run npm install source-map-support --save at the root of your node project and add import 'source-map-support/register' to your main.ts or index.ts file. That's ......
Read more >
Source Maps - Rollbar Docs
You'll get one of these if you give Rollbar an Error, in a browser that ... but not suitable for all cases (e.g....
Read more >
Source Maps - SurviveJS
One approach is to skip source maps during development and rely on browser support of language features. If you use ES2015 without any...
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