node-source-map-support icon indicating copy to clipboard operation
node-source-map-support copied to clipboard

Activating source-map-support several times leads to issues

Open renehamburger opened this issue 7 years ago • 6 comments

I've just encountered the fact that Protractor tests in TypeScript run via ts-node leads to broken stack traces, as both Protractor and ts-node call require('source-map-support').install() by default. See this issue at ts-node and this example repo.

In this case, the solution is simple, as Protactor allows to switch off source map support, but it would be worth to either investigate this bug or log an error message to notify the user that souce-map-support was activated twice.

renehamburger avatar Jan 14 '18 16:01 renehamburger

Maybe it would be good to guard against double initialisation with a simple global variable? Would you be up for making a pr?

LinusU avatar Jan 16 '18 17:01 LinusU

I'm having the same issue when using ts-node in combination with node-tap; lines and columns in stack traces are way off.

kasperisager avatar Feb 22 '18 10:02 kasperisager

One problem is different packages loading different versions of source-map-support. Going forward, I think if a registered Symbol could be added to prepareStackTrack, that could be used to avoid overwriting a previous installation.

That said we may also need a way to register multiple retrievers, even across source-map-support packages.

This has been affecting AVA, see https://github.com/avajs/ava/issues/1899#issuecomment-416204989 for my latest investigation into the matter.

novemberborn avatar Aug 27 '18 12:08 novemberborn

Still running into this problem two years later. As @LinusU mentioned, a simple global variable should suffice for this. Is there a reason why a fix hasn't been included yet, i.e. is it not that simple?

ghost avatar Apr 02 '20 19:04 ghost

@evanw @LinusU I am more than happy to make a PR to fix this. Should I go ahead?

This is still causing some problems. Related issues: https://github.com/nomiclabs/hardhat/issues/1336 and https://github.com/EthWorks/Waffle/issues/281

krzkaczor avatar Mar 19 '21 17:03 krzkaczor

This library already detects if a particular version is loaded multiple times. If you use yarn you can force it to always install only one version.

In package.json:

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

This is a quite reasonable workaround IMO.

krzkaczor avatar Mar 21 '21 13:03 krzkaczor