Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upVM: 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:7But 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:27Note 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 |


In vm.runInNewContext (and maybe other versions of "run", too), the
options.columnOffsethas no effect. I've tried a couple of intentionally-caused errors with variouscolumnOffsetvalues (ranging from -5 to 5), but the character position reported in the stack trace (viae.stack) is always the same. Note thatlineOffsetworks as expected.