-
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
lib: refactor console bootstrap #15111
Conversation
has nodejs/help#778 been fixed otherwise in the last 19 days? Can you explain why da1af3d is no longer required? |
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.
Requesting changes so I don't forget this
Thanks, cc @bnoordhuis |
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.
little unsure why some bits were changed?
lib/internal/bootstrap_node.js
Outdated
if (browserGlobals) { | ||
setupGlobalTimeouts(); | ||
setupGlobalConsole(); | ||
} |
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.
It is desirable to load the console first for debugging reasons.
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.
Well that is a bit tricky if we want to instantiate it eagerly without the get call to do the Instantiation because internal/process/stdio
has to be loaded first. Would it be fine to move the necessary part up that load stdio
and keep the eager instantiation?
lib/internal/bootstrap_node.js
Outdated
if (browserGlobals) { | ||
// Instantiate eagerly in case the first call is under stack overflow | ||
// conditions where instantiation doesn't work. |
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 previous commit here still seems valid...?
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.
Somewhat yes, but it did not fully work as anticipated and therefore I think it is fine to remove the comment. I can add the comment back in if you like though.
lib/internal/bootstrap_node.js
Outdated
@@ -312,62 +297,48 @@ | |||
|
|||
function setupGlobalConsole() { | |||
const originalConsole = global.console; | |||
let console; | |||
// Setup inspector command line API | |||
const { addCommandLineAPI, consoleCall } = process.binding('inspector'); |
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.
needs if (!addCommandLineAPI) return;
?
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.
Oh, you are right, this part should be moved below the if (!consoleCall)
statement. That should be sufficient.
const consoleAPIModule = new Module('<inspector console>'); | ||
consoleAPIModule.paths = | ||
Module._nodeModulePaths(cwd).concat(Module.globalPaths); | ||
addCommandLineAPI('require', makeRequireFunction(consoleAPIModule)); |
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.
This is frankly unrelated to console
instantiation. I'd prefer it to be moved out of console bootstrapping.
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 combined them because it was the only function calling the inspector. But I split them and the inspector part is now separated.
@Fishrock123 @TimothyGu PTAL |
@nodejs/collaborators PTAL |
Since this should actually also fix a bug (see #15008 (comment)) it would be nice to get some reviews. |
LGTM if CI is happy |
Landed in 4bcb1c3 |
PR-URL: #15111 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: #15111 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: nodejs/node#15111 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: nodejs/node#15111 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Previously, console had to be compiled in case it was not available but this is no longer necessary - remove it. Refs: nodejs#15111
Previously, console had to be compiled in case it was not available but this is no longer necessary - remove it. PR-URL: nodejs#16212 Refs: nodejs#15111 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Previously, console had to be compiled in case it was not available but this is no longer necessary - remove it. PR-URL: nodejs/node#16212 Refs: nodejs/node#15111 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Previously, console had to be compiled in case it was not available but this is no longer necessary - remove it. PR-URL: nodejs/node#16212 Refs: nodejs/node#15111 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
I do not see much benefit to backport this, so I changed the label accordingly. |
Console setup is currently more complicated then it has to be. I refactored it to be more straight forward.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
lib, test