-
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
console: minor console refactoring #17707
Conversation
Calling write could throw a maximum call stack size error. To make sure this is not specific to a single engine (version), lazily populate the correct error message by producing such a error on demand.
lib/console.js
Outdated
@@ -50,7 +52,7 @@ function Console(stdout, stderr, ignoreErrors = true) { | |||
Object.defineProperty(this, '_stdout', prop); | |||
prop.value = stderr; | |||
Object.defineProperty(this, '_stderr', prop); | |||
prop.value = ignoreErrors; | |||
prop.value = !!ignoreErrors; |
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.
Using Boolean(ignoreErrors)
might be more readable here.
lib/console.js
Outdated
|
||
Console.prototype.warn = function warn(...args) { | ||
write(this._ignoreErrors, | ||
this._stderr, | ||
util.format.apply(null, args), | ||
util.format(...args), |
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 spread operator, unlike .apply(), pushes the elements onto the stack. That is, it makes stack overflows more likely.
bc57bcb
to
ce00d93
Compare
ce00d93
to
74755f0
Compare
Fix and refactor the console benchmark. It did not test console so it got renamed and mainly tests the different ways of passing arguments through.
This lists all function aliases directly below the declared function.
This should not be important anymore in newer docs. The change is also documented in the "changed" part of the function.
74755f0
to
2dc5813
Compare
Comments addressed. I removed the spread operator again and added a comment about it. |
benchmark/misc/arguments.js
Outdated
n: [1e6] | ||
}); | ||
|
||
const nullStream = createNullStream(); |
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.
Unrelated but can't this be simplified to just new Writable({ write: () => {} })
?
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 went ahead and removed the fake console overall as it had no real purpose in this benchmark.
Calling write could throw a maximum call stack size error. To make sure this is not specific to a single engine (version), lazily populate the correct error message by producing such a error on demand. PR-URL: nodejs#17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fix and refactor the console benchmark. It did not test console so it got renamed and mainly tests the different ways of passing arguments through. PR-URL: nodejs#17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This lists all function aliases directly below the declared function. PR-URL: nodejs#17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This should not be important anymore in newer docs. The change is also documented in the "changed" part of the function. PR-URL: nodejs#17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Calling write could throw a maximum call stack size error. To make sure this is not specific to a single engine (version), lazily populate the correct error message by producing such a error on demand. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fix and refactor the console benchmark. It did not test console so it got renamed and mainly tests the different ways of passing arguments through. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This lists all function aliases directly below the declared function. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This should not be important anymore in newer docs. The change is also documented in the "changed" part of the function. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Calling write could throw a maximum call stack size error. To make sure this is not specific to a single engine (version), lazily populate the correct error message by producing such a error on demand. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fix and refactor the console benchmark. It did not test console so it got renamed and mainly tests the different ways of passing arguments through. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This lists all function aliases directly below the declared function. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This should not be important anymore in newer docs. The change is also documented in the "changed" part of the function. PR-URL: #17707 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
should this be backported to v6.x or v8.x? |
This comment has been minimized.
This comment has been minimized.
@BridgeAR should this be backported? |
Some minor changes
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
console, doc, benchmark