-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
repl: wrong repl stack trace column number in strict mode #5416
Conversation
@@ -289,6 +289,10 @@ function REPLServer(prompt, | |||
debug('domain error'); | |||
const top = replMap.get(self); | |||
internalUtil.decorateErrorStack(e); | |||
if (e.stack && self.replMode === exports.REPL_MODE_STRICT) { | |||
e.stack = e.stack.replace(/(\s+at\s+repl:)(\d+)/, | |||
(_, pre, line) => pre + (parseInt(line) - 1)); |
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 don't think we need the parseInt()
here, "3" - 1
will be faster, and the regex is going to guarantee an integer anyway.
Edit: also the parenthesis around the 2nd math seem to be extraneous.
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.
@Fishrock123 parseInt
is removed. parenthesis around subtraction is required because arithmetic operators are left associative and pre
is a string.
LGTM once CI is back online so that we can run the tests |
LGTM |
On strict mode, "'use strict'; void 0; " is added as prefix in order to prevent "use strict" as the result value for let/const statements. It causes wrong column number in stack trace.
5bd3401
to
00ebc4e
Compare
@silverwind Green build? |
Yes! |
Thanks! Landed in 40d57b7. |
On strict mode, "'use strict'; void 0; " is added as prefix in order to prevent "use strict" as the result value for let/const statements. It causes wrong column number in stack trace. PR-URL: #5416 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
Marked for LTS watch... still need to verify that this bug is relevant for v4, however. /cc @nodejs/lts |
On strict mode, "'use strict'; void 0; " is added as prefix in order to prevent "use strict" as the result value for let/const statements. It causes wrong column number in stack trace. PR-URL: #5416 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
one more ping to @nodejs/lts |
I've gone through and manually followed the reproduction steps and saw this error on v4. After backporting the change things are fixed. As such I'm moving this to staging. |
On strict mode, "'use strict'; void 0; " is added as prefix in order to prevent "use strict" as the result value for let/const statements. It causes wrong column number in stack trace. PR-URL: #5416 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
On strict mode, "'use strict'; void 0; " is added as prefix in order to prevent "use strict" as the result value for let/const statements. It causes wrong column number in stack trace. PR-URL: #5416 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
Notable Changes * https: - Under certain conditions ssl sockets may have been causing a memory leak when keepalive is enabled. This is no longer the case. - (Alexander Penev) #5713 * lib: - The way that we were internally passing arguments was causing a potential leak. By copying the arguments into an array we can avoid this - (Nathan Woltman) #4361 * repl: - Previously if you were using the repl in strict mode the column number would be wrong in a stack trace. This is no longer an issue. - (Prince J Wesley) #5416 PR-URL: #5961
Notable Changes * https: - Under certain conditions ssl sockets may have been causing a memory leak when keepalive is enabled. This is no longer the case. - (Alexander Penev) #5713 * lib: - The way that we were internally passing arguments was causing a potential leak. By copying the arguments into an array we can avoid this - (Nathan Woltman) #4361 * npm: - Upgrade to v2.15.1. (Forrest L Norvell) * repl: - Previously if you were using the repl in strict mode the column number would be wrong in a stack trace. This is no longer an issue. - (Prince J Wesley) #5416 PR-URL: #5961
Notable Changes * https: - Under certain conditions ssl sockets may have been causing a memory leak when keepalive is enabled. This is no longer the case. - (Alexander Penev) #5713 * lib: - The way that we were internally passing arguments was causing a potential leak. By copying the arguments into an array we can avoid this - (Nathan Woltman) #4361 * npm: - Upgrade to v2.15.1. Fixes a security flaw in the use of authentication tokens in HTTP requests that would allow an attacker to set up a server that could collect tokens from users of the command-line interface. Authentication tokens have previously been sent with every request made by the CLI for logged-in users, regardless of the destination of the request. This update fixes this by only including those tokens for requests made against the registry or registries used for the current install. (Forrest L Norvell) * repl: - Previously if you were using the repl in strict mode the column number would be wrong in a stack trace. This is no longer an issue. - (Prince J Wesley) #5416 PR-URL: #5961
Notable Changes * https: - Under certain conditions ssl sockets may have been causing a memory leak when keepalive is enabled. This is no longer the case. - (Alexander Penev) #5713 * lib: - The way that we were internally passing arguments was causing a potential leak. By copying the arguments into an array we can avoid this - (Nathan Woltman) #4361 * npm: - Upgrade to v2.15.1. Fixes a security flaw in the use of authentication tokens in HTTP requests that would allow an attacker to set up a server that could collect tokens from users of the command-line interface. Authentication tokens have previously been sent with every request made by the CLI for logged-in users, regardless of the destination of the request. This update fixes this by only including those tokens for requests made against the registry or registries used for the current install. (Forrest L Norvell) * repl: - Previously if you were using the repl in strict mode the column number would be wrong in a stack trace. This is no longer an issue. - (Prince J Wesley) #5416 PR-URL: #5961
Pull Request check-list
make -j8 test
(UNIX) orvcbuild test nosign
(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)?
Affected core subsystem(s)
repl
Description of change
This PR addresses the below problem.
Problem
On REPL strict mode,
'use strict'; void 0;
is added as prefix in order to prevent"use strict"
as the result value forlet
/const
statements. It causes wrong column number instack trace.
Code for REPL with strict mode
Output
Behavior
Length of
'use strict'; void 0;
(22 chars) is added up to column number. ❌Output (after fix)