-
Notifications
You must be signed in to change notification settings - Fork 30k
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
util: don't init Debug if it's not needed yet #8452
Conversation
Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check.
LGTM pending CI (also, TIL Node has awesome things like |
LGTM |
@@ -301,10 +301,10 @@ function ensureDebugIsInitialized() { | |||
|
|||
|
|||
function inspectPromise(p) { | |||
ensureDebugIsInitialized(); | |||
// Only create a mirror if the object is a Promise. |
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 comment should probably be moved also
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.
Where to? Wouldn't the best place for the comment about checking whether it's a promise be right before the line that checks if it's a promise?
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 guess to me it's a little confusing since the comment is talking about creating a mirror which isn't done on the next line and the function name does not indicate that a mirror is being created. shrug
CI failures are strange, especially SmartOS. I suspect temporary infra borkage. Let's try again: |
CI failures now seem less problematic:
TL;DR: CI looks good: |
LGTM. Transient error on the arm buildbot and sequential/test-crypto-timing-safe-equal failure on one of the linux buildbots. Unlikely to be caused by this PR. |
LGTM |
2 similar comments
LGTM |
LGTM |
trying CI again: https://ci.nodejs.org/job/node-test-pull-request/4024/ |
kicking CI one more time in hopes of all green: https://ci.nodejs.org/job/node-test-pull-request/4078/ |
Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check. PR-URL: #8452 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
The failures look like flaky issues to me. Hope you don't mind that I went ahead and landed in be07458 |
Don't mind at all 👍 |
Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check. PR-URL: #8452 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
ping @nodejs/lts |
This is a safe performance fix. I would be mildly in favour of backporting. |
Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check. PR-URL: #8452 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check. PR-URL: #8452 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
util
Description of change
Because any call to
util.inspect()
with an object results ininspectPromise()
being called,Debug
was being initialized even whenit's not needed. Instead, the initialization is placed after the
isPromise
check.