-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error stack gives incorrect column number #2860
Comments
If you look at the error, you'll see that Your module/code gets wrapped before being executed. Does this happen when it's on its' own line? |
Node wraps everything inside a function. This PR may be relevant - nodejs/node-v0.x-archive#25342 |
Removing the iife produces the same problem. Code: var functions = { test: function() { throw new Error('testing'); } }; functions.test(); trace:
Again, column 106 is past the end of the file (now 88) |
In fact, it's as simple as: throw new Error('test'); trace:
|
You're not understanding what's happening. Your code gets wrapped by The error is correct. |
If that's the case then it's a pretty leaky abstraction that makes stacktraces totally unreliable. Is there any way for node to translate traces so they are accurate to the actual source? |
#2867 fixes this issue |
C:\Users\Administrator\AppData\Roaming\npm\node_modules\nvmw\node_modules\adm-zip\zipFil how can i solve the problem |
Because Node modules are wrapped, errors on the first line of a file leak the wrapper to the user and report the wrong column number. This commit adds a line break to the module wrapper so that the first line is treated the same as all other lines. To compensate for the additional line, a line offset of -1 is also applied to errors. Fixes: #2860 PR-URL: #2867 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Because Node modules are wrapped, errors on the first line of a file leak the wrapper to the user and report the wrong column number. This commit adds a line break to the module wrapper so that the first line is treated the same as all other lines. To compensate for the additional line, a line offset of -1 is also applied to errors. Fixes: #2860 PR-URL: #2867 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Because Node modules are wrapped, errors on the first line of a file leak the wrapper to the user and report the wrong column number. This commit adds a line break to the module wrapper so that the first line is treated the same as all other lines. To compensate for the additional line, a line offset of -1 is also applied to errors. Fixes: #2860 PR-URL: #2867 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Seems the issue can be reproduced in node 6.6.0 using the simple example: throw Error("Hello, I'm back");
|
The fix was reverted in #4298 because it introduced a regression. I'll reopen this issue. |
this is a very old defect, so checking some basic sanity first:
|
Still an issue but implementing #17396 would fix it. We're at a new enough V8 now that we could. |
At the time, it was a V8 issue - https://bugs.chromium.org/p/v8/issues/detail?id=4620. While the issue is still open, I'm not sure what the actual status of the bug is. |
I think this issue has been already fixed? |
Yes, I believe so; we're using |
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:
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.
The text was updated successfully, but these errors were encountered: