Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

BridgeAR
Copy link
Member

Console setup is currently more complicated then it has to be. I refactored it to be more straight forward.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

lib, test

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Aug 31, 2017
@benjamingr
Copy link
Member

has nodejs/help#778 been fixed otherwise in the last 19 days?

Can you explain why da1af3d is no longer required?

Copy link
Member

@benjamingr benjamingr left a 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

@BridgeAR
Copy link
Member Author

For question 1 please look at #15110 (it was only seemingly fixed but not really fixed).

The initiation of global.console is not necessary anymore because that was originally done in the get of global.console and now it is done right away. That is why the test added by da1af3d continues to "work".

@benjamingr
Copy link
Member

Thanks, cc @bnoordhuis

@addaleax addaleax self-requested a review August 31, 2017 13:25
Copy link
Contributor

@Fishrock123 Fishrock123 left a 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?

if (browserGlobals) {
setupGlobalTimeouts();
setupGlobalConsole();
}
Copy link
Contributor

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.

Copy link
Member Author

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?

if (browserGlobals) {
// Instantiate eagerly in case the first call is under stack overflow
// conditions where instantiation doesn't work.
Copy link
Contributor

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...?

Copy link
Member Author

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.

@@ -312,62 +297,48 @@

function setupGlobalConsole() {
const originalConsole = global.console;
let console;
// Setup inspector command line API
const { addCommandLineAPI, consoleCall } = process.binding('inspector');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs if (!addCommandLineAPI) return;?

Copy link
Member Author

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));
Copy link
Member

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.

Copy link
Member Author

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.

@nodejs nodejs deleted a comment Sep 3, 2017
@nodejs nodejs deleted a comment Sep 3, 2017
@nodejs nodejs deleted a comment Sep 3, 2017
@BridgeAR
Copy link
Member Author

BridgeAR commented Sep 8, 2017

@Fishrock123 @TimothyGu PTAL

@BridgeAR
Copy link
Member Author

@nodejs/collaborators PTAL

@BridgeAR
Copy link
Member Author

BridgeAR commented Sep 15, 2017

Since this should actually also fix a bug (see #15008 (comment)) it would be nice to get some reviews.

@targos
Copy link
Member

targos commented Sep 18, 2017

LGTM if CI is happy

@BridgeAR
Copy link
Member Author

@BridgeAR
Copy link
Member Author

Landed in 4bcb1c3

@BridgeAR BridgeAR closed this Sep 19, 2017
BridgeAR added a commit that referenced this pull request Sep 19, 2017
PR-URL: #15111
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
jasnell pushed a commit that referenced this pull request Sep 20, 2017
PR-URL: #15111
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
PR-URL: nodejs/node#15111
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
PR-URL: nodejs/node#15111
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
apapirovski added a commit to apapirovski/node that referenced this pull request Oct 15, 2017
Previously, console had to be compiled in case it was not available
but this is no longer necessary - remove it.

Refs: nodejs#15111
apapirovski added a commit to apapirovski/node that referenced this pull request Oct 21, 2017
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>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Oct 26, 2017
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>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
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>
@BridgeAR
Copy link
Member Author

I do not see much benefit to backport this, so I changed the label accordingly.

@BridgeAR BridgeAR deleted the refactor-console-bootstrap branch April 1, 2019 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants