Node.js appears to give incorrect column numbers in it's stack traces. The problem is magnified when running uglified/minified code (because all the code tends to be on a single line). Here's a trivial example that show's the problem:
code:
(function() { var functions = { test: function() { throw new Error('testing'); } }; functions.test(); })();
stacktrace:
/Users/mbrocato/WebstormProjects/StackTest/test.js:1
dirname) { (function() { var functions = { test: function() { throw new Error(
^
Error: testing
at Object.functions.test (/Users/mbrocato/WebstormProjects/StackTest/test.js:1:120)
at /Users/mbrocato/WebstormProjects/StackTest/test.js:1:157
at Object.<anonymous> (/Users/mbrocato/WebstormProjects/StackTest/test.js:1:167)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
The correct column number is 58. Column 120 is actually past the end of the file (the last column is 108).
I've tested this using 4.0.0 and 0.12.7. Both yield the same results.
Reactions are currently unavailable
Node.js appears to give incorrect column numbers in it's stack traces. The problem is magnified when running uglified/minified code (because all the code tends to be on a single line). Here's a trivial example that show's the problem:
code:
stacktrace:
/Users/mbrocato/WebstormProjects/StackTest/test.js:1 dirname) { (function() { var functions = { test: function() { throw new Error( ^ Error: testing at Object.functions.test (/Users/mbrocato/WebstormProjects/StackTest/test.js:1:120) at /Users/mbrocato/WebstormProjects/StackTest/test.js:1:157 at Object.<anonymous> (/Users/mbrocato/WebstormProjects/StackTest/test.js:1:167) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3The correct column number is 58. Column 120 is actually past the end of the file (the last column is 108).
I've tested this using 4.0.0 and 0.12.7. Both yield the same results.