AndreasMadsen / trace

Creates super long stack traces
https://trace.js.org
MIT License
194 stars 18 forks source link

Error: Conflicting version of stack-chain found #53

Closed joniba closed 5 years ago

joniba commented 5 years ago

Hi, I'm trying to use this package to get errors when running cucumber.js, but I get Error: Conflicting version of stack-chain found when trying to run them together.

cucumber version 1.3.2

Command: node --stack_trace_limit=100 -r trace .\node_modules\cucumber\bin\cucumber.js .\some\path\to\a.feature -r features

Output: Error: Conflicting version of stack-chain found at Object. (C:\redacated\node_modules\stack-chain\index.js:10:11) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\redacated\node_modules\cucumber\lib\cucumber\runtime\stack_trace_filter.js:2:13) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\redacated\node_modules\cucumber\lib\cucumber\runtime.js:59:40) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\redacated\node_modules\cucumber\lib\cucumber.js:14:34) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\redacated\node_modules\cucumber\bin\cucumber.js:2:16) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:188:16) at bootstrap_node.js:609:3

AndreasMadsen commented 5 years ago

Either cucumber or trace is using an old version of stack-chain. I'm the author of stack-chain, so I guess it is cucumber. You can check it yourself by looking up the stack-chain dependency directory and look in the package.json file for both cucumber and trace.

This is necessary because Error.prepareStackTrace, which is what controls what error.stack will output can only be set once. stack-chain attempts to add some interoperability, but if there are different versions of it then it can't work.

AndreasMadsen commented 5 years ago

The latest of stack-chain version is 2.0.0, which is what `trace depends on, so I'm closing this as there is little I can do.

joniba commented 5 years ago

Well I just changed the stack-chain code to:

if (global._stackChain) { 
    module.exports = global._stackChain;
}
// Yay, no other stack-chain copy exists, yet :/
else {
  module.exports = global._stackChain = require('./stack-chain');
}

And it seems to work fine. I don't get double call sites or anything. So it seems to me like you can just pick one of the versions (preferably the newer one) and it will work fine. Why throw an error and prevent the package from being used? Unfortunately, I can't update cucumber and wouldn't want to fork it for such an issue.

AndreasMadsen commented 5 years ago

So it seems to me like you can just pick one of the versions (preferably the newer one) and it will work fine.

You most definitely can't. For some use cases (this could be one) it might not break anything critical but for others things will definitely break. Hence it throws an error.

I can't update cucumber and wouldn't want to fork it for such an issue.

Well, that is entirely up to you. The issue is with cucumber.