-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: add guard to originalConsole #12881
Conversation
lib/internal/bootstrap_node.js
Outdated
try { | ||
inspector = process.binding('inspector'); | ||
} catch (ignored) { | ||
return wrappedConsole; |
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.
You skipping over loop in L280.
@danbev IMHO you need to do the bypass higher up the call stack... Ping @eugeneo, if there's no |
lib/internal/bootstrap_node.js
Outdated
inspector = process.binding('inspector'); | ||
} catch (ignored) { | ||
return wrappedConsole; | ||
} | ||
const config = {}; | ||
for (const key of Object.keys(wrappedConsole)) { | ||
if (!globalConsole.hasOwnProperty(key)) |
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 error message suggests that globalConsole
is undefined
, right? Shouldn't the fix be installing a guard for it?
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.
Yep, that is correct. I'm not sure now what I was thinking as that sounds much more sensible (or if I ran into some different issue doing that) but I'll take a closer look at this tomorrow.
Thanks, will take a closer at this now. |
lib/internal/bootstrap_node.js
Outdated
@@ -261,7 +261,8 @@ | |||
enumerable: true, | |||
get: function() { | |||
if (!console) { | |||
console = installInspectorConsole(originalConsole); | |||
console = originalConsole ? installInspectorConsole(originalConsole) : |
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 makes much more sense 👍
Is this the right check? i.e. if inspector
is "on" global.console
will be true
?
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.
LGTM with a comment.
lib/internal/bootstrap_node.js
Outdated
@@ -261,7 +261,8 @@ | |||
enumerable: true, | |||
get: function() { | |||
if (!console) { | |||
console = installInspectorConsole(originalConsole); | |||
console = originalConsole ? installInspectorConsole(originalConsole) : |
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.
Can the originalConsole
check be stricter? Such as checking explicitly against undefined
.
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.
Ya, even I was thinking about.
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.
Yeah, that sounds better. I'll add a more strict check.
Currently when building --without-ssl or --without-inspector there will be an error when trying to set up the console in bootstrap_node.js: Can't determine the arch of: 'out/Release/node' bootstrap_node.js:276 if (!globalConsole.hasOwnProperty(key)) ^ TypeError: Cannot read property 'hasOwnProperty' of undefined at installInspectorConsole (bootstrap_node.js:276:25) at get (bootstrap_node.js:264:21) at evalScript (bootstrap_node.js:395:30) at startup (bootstrap_node.js:125:9) at bootstrap_node.js:537:3 I think this issue was introduced in commit 3f48ab3 ("inspector: do not add 'inspector' property"). This commit attempts to fix this.
bfe87c1
to
96d228c
Compare
test/windows-fanned looks unrelated to this PR: ERROR: Error fetching remote repo 'jenkins_tmp'
hudson.plugins.git.GitException: Failed to fetch from git@github.com:janeasystems/node_binary_tmp.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:809)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1076)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1107)
at hudson.scm.SCM.checkout(SCM.java:496)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1281)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1728)
at hudson.matrix.MatrixRun.run(MatrixRun.java:146)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:405)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@github.com:janeasystems/node_binary_tmp.git +refs/heads/jenkins-node-test-commit-windows-fanned-8962-binary-windows/*:refs/remotes/jenkins_tmp/jenkins-node-test-commit-windows-fanned-8962-binary-windows/*" returned status code 128: |
Currently when building --without-ssl or --without-inspector there will be an error when trying to set up the console in bootstrap_node.js: Can't determine the arch of: 'out/Release/node' bootstrap_node.js:276 if (!globalConsole.hasOwnProperty(key)) ^ TypeError: Cannot read property 'hasOwnProperty' of undefined at installInspectorConsole (bootstrap_node.js:276:25) at get (bootstrap_node.js:264:21) at evalScript (bootstrap_node.js:395:30) at startup (bootstrap_node.js:125:9) at bootstrap_node.js:537:3 I think this issue was introduced in commit 3f48ab3 ("inspector: do not add 'inspector' property"). This commit attempts to fix this. PR-URL: nodejs#12881 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Landed in 54d3318 |
Currently when building --without-ssl or --without-inspector there will be an error when trying to set up the console in bootstrap_node.js: Can't determine the arch of: 'out/Release/node' bootstrap_node.js:276 if (!globalConsole.hasOwnProperty(key)) ^ TypeError: Cannot read property 'hasOwnProperty' of undefined at installInspectorConsole (bootstrap_node.js:276:25) at get (bootstrap_node.js:264:21) at evalScript (bootstrap_node.js:395:30) at startup (bootstrap_node.js:125:9) at bootstrap_node.js:537:3 I think this issue was introduced in commit 3f48ab3 ("inspector: do not add 'inspector' property"). This commit attempts to fix this. PR-URL: nodejs#12881 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Should this be backported to |
Currently when building --without-ssl or --without-inspector there will
be an error when trying to set up the console in bootstrap_node.js:
I think this issue was introduced in commit
3f48ab3 ("inspector: do not add
'inspector' property").
This commit attempts to fix this.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passeslib
Affected core subsystem(s)