-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
VM: options.columnOffset has no effect on column number in stack trace output #26780
Comments
I can't reproduce this in 10.15.3
|
@devsnek : Yes, I get the same results with your example, but it appears to only work when the VM code is a single line. I've created a stripped-down version of my code that shows the one change that makes it work or not: In this example, let code = `
throw new Error();
`;
vm.runInNewContext(code, {}, {columnOffset: 20});
// RESULT (truncated):
evalmachine.<anonymous>:2
throw new Error();
^
Error
at evalmachine.<anonymous>:2:7 But in this example, it works: let code = `throw new Error();`;
vm.runInNewContext(code, {}, {columnOffset: 20});
// RESULT (truncated):
evalmachine.<anonymous>:1
throw new Error();
^
Error
at evalmachine.<anonymous>:1:27 Note that the only difference is whether PS - The "line" difference between the two examples is expected, and this is easily adjusted using |
The column offset only affects the first line. The reason column offset exists is for script tags in html: <body>
<script>maybe code
code
code
code
</script>
</body> Every line that isn't the first script tag line has a correct column no matter what, because they start fromt the 1st column. But the source of the js in the first line is offset by 10 ( |
Hmmm. OK. I guess that explains what I'm seeing. If it's only supposed to affect the first line, then maybe this is just a documentation update. |
Marking this as a good first issue doc update. |
@jasnell Can I do this? |
Please feel free! |
@jasnell I am adding Note beside columnOffset definition |
Hi @jasnell , I don't known if this doc issue update was already made, but, if not, could I give it a shot? |
sorry, just saw the notification on this. It appears that this is still up for someone to take on! |
In vm.runInNewContext (and maybe other versions of "run", too), the
options.columnOffset
has no effect. I've tried a couple of intentionally-caused errors with variouscolumnOffset
values (ranging from -5 to 5), but the character position reported in the stack trace (viae.stack
) is always the same. Note thatlineOffset
works as expected.The text was updated successfully, but these errors were encountered: