-
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
module: fix error first line col offset #2867
Conversation
76c8ac5
to
9c0f78b
Compare
I feel like @brendan0powers's authorship should be preserved here. |
👍 Just looking for things to do (this seemed rather important) |
Are there any side effects of using the second commit (tflanagan@9d8e6a9)? It seems way simpler. |
@@ -41,6 +41,10 @@ e.g. `(0,eval)('code')`. However, it also has the following additional options: | |||
|
|||
- `filename`: allows you to control the filename that shows up in any stack | |||
traces produced. | |||
- `lineOffset`: allows you to add an offset to the line number that is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to also update docs on Script constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the docs in two places with the lineOffset and columnOffset parameters, and also added a missing filename and timeout parameter listings.
I agree with @brendanashworth that the other commit looks much simpler. Does it cause any issues on Windows? |
bump for LTS? Don't want this PR to end up like @brendan0powers's |
@tflanagan does tflanagan@489b5b4 cause any issues (perhaps windows)? I think this should be pushed instead of the other bigger commits. But this would be a candidate for LTS back-porting anyways. |
I've beening running it on windows for over 3 weeks without issues, granted any issue would only show if an error occured |
@tflanagan could you push only that commit to this PR then? Then we can review and run the CI. |
489b5b4
to
41810b8
Compare
@brendanashworth okay, i've rebased/amended/pushed it down to one commit with the NL approach.
|
poke edit: poke |
@@ -60,3 +60,23 @@ var ctx = {}; | |||
Object.defineProperty(ctx, 'b', { configurable: false }); | |||
ctx = vm.createContext(ctx); | |||
assert.equal(script.runInContext(ctx), false); | |||
|
|||
// Issue GH-2860 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first line of this comment can probably be removed.
@tflanagan I'm interested in getting this landed. Would you mind rebasing? |
@cjihrig Rebased, running new tests now, will force push shortly |
41810b8
to
7dc621b
Compare
@cjihrig Done. Besides for those pesky flaky Buffer tests, it passes local tests fwiw Edit: Fixed the docs |
b28d69a
to
1505c73
Compare
1505c73
to
e4281ca
Compare
Thanks. LGTM. CI: https://ci.nodejs.org/job/node-test-pull-request/800/ |
@cjihrig Looks like it passed! :) 💯 |
💚 from the CI. Nice. Landing. |
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>
Thanks! Landed in dfee4e3 |
Thank you! 👍 |
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>
In dfee4e3, the module wrapper and line offset used when wrapping module code was changed to better report errors on the first line of modules. However, that commit did not update the runInThisContext() call used to execute the core modules, so their error line numbers have been off by one. This commit provides the correct lineOffset for core modules. Refs: nodejs#2867 PR-URL: nodejs#4254 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
In dfee4e3, the module wrapper and line offset used when wrapping module code was changed to better report errors on the first line of modules. However, that commit did not update the runInThisContext() call used to execute the core modules, so their error line numbers have been off by one. This commit provides the correct lineOffset for core modules. Refs: #2867 PR-URL: #4254 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
In dfee4e3, the module wrapper and line offset used when wrapping module code was changed to better report errors on the first line of modules. However, that commit did not update the runInThisContext() call used to execute the core modules, so their error line numbers have been off by one. This commit provides the correct lineOffset for core modules. Refs: #2867 PR-URL: #4254 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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>
In dfee4e3, the module wrapper and line offset used when wrapping module code was changed to better report errors on the first line of modules. However, that commit did not update the runInThisContext() call used to execute the core modules, so their error line numbers have been off by one. This commit provides the correct lineOffset for core modules. Refs: #2867 PR-URL: #4254 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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>
In dfee4e3, the module wrapper and line offset used when wrapping module code was changed to better report errors on the first line of modules. However, that commit did not update the runInThisContext() call used to execute the core modules, so their error line numbers have been off by one. This commit provides the correct lineOffset for core modules. Refs: #2867 PR-URL: #4254 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
In dfee4e3, the module wrapper and line offset used when wrapping module code was changed to better report errors on the first line of modules. However, that commit did not update the runInThisContext() call used to execute the core modules, so their error line numbers have been off by one. This commit provides the correct lineOffset for core modules. Refs: nodejs#2867 PR-URL: nodejs#4254 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Rehash of nodejs/node-v0.x-archive#25342 with noted corrections.
Fixes #2860, nodejs/node-v0.x-archive#9445
I've also created another variant of this solution by adding a "\n" to the wrapper and setting the
lineOffset
property to-1
, re: tflanagan@9d8e6a9