-
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
console: fix issues with frozen intrinsics #54070
Conversation
this[kInternalTimeLogImpl] = FunctionPrototypeBind(timeLogImpl, this); | ||
|
||
timeLog(this._times, kTraceConsoleCategory, 'console.timeLog()', kNone, this[kInternalTimeLogImpl], label, `time::${label}`, data); | ||
timeLog(this._times, kTraceConsoleCategory, 'console.timeLog()', kNone, (label, formatted, args) => timeLogImpl(this, label, formatted, args), label, `time::${label}`, data); |
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 believe it would be possible to add the timeLogImpl to the instance during construction time.
That way it is not required to recreate the function on each call.
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 tried adding inside the constructor but I always get undefined
.
diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js
index 6c34a9eded..8d88d429b0 100644
--- a/lib/internal/console/constructor.js
+++ b/lib/internal/console/constructor.js
@@ -90,6 +90,7 @@ const kBindStreamsEager = Symbol('kBindStreamsEager');
const kBindStreamsLazy = Symbol('kBindStreamsLazy');
const kUseStdout = Symbol('kUseStdout');
const kUseStderr = Symbol('kUseStderr');
+const kInternalTimeLogImpl = Symbol('kInternalTimeLogImpl');
const optionsMap = new SafeWeakMap();
function Console(options /* or: stdout, stderr, ignoreErrors = true */) {
@@ -155,6 +156,8 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) {
});
});
+ this[kInternalTimeLogImpl] = FunctionPrototypeBind(timeLogImpl, this);
+
this[kBindStreamsEager](stdout, stderr);
this[kBindProperties](ignoreErrors, colorMode, groupIndentation);
}
@@ -371,11 +374,11 @@ function createWriteErrorHandler(instance, streamSymbol) {
};
}
-function timeLogImpl(consoleRef, label, formatted, args) {
+function timeLogImpl(label, formatted, args) {
if (args === undefined) {
- consoleRef.log('%s: %s', label, formatted);
+ this.log('%s: %s', label, formatted);
} else {
- consoleRef.log('%s: %s', label, formatted, ...new SafeArrayIterator(args));
+ this.log('%s: %s', label, formatted, ...new SafeArrayIterator(args));
}
}
@@ -406,11 +409,11 @@ const consoleMethods = {
},
timeEnd(label = 'default') {
- timeEnd(this._times, kTraceConsoleCategory, 'console.timeEnd()', kNone, (label, formatted, args) => timeLogImpl(this, label, formatted, args), label, `time::${label}`);
+ timeEnd(this._times, kTraceConsoleCategory, 'console.timeEnd()', kNone, this[kInternalTimeLogImpl], label, `time::${label}`);
},
timeLog(label = 'default', ...data) {
- timeLog(this._times, kTraceConsoleCategory, 'console.timeLog()', kNone, (label, formatted, args) => timeLogImpl(this, label, formatted, args), label, `time::${label}`, data);
+ timeLog(this._times, kTraceConsoleCategory, 'console.timeLog()', kNone, this[kInternalTimeLogImpl], label, `time::${label}`, data);
},
trace: function trace(...args) {
node:internal/util/debuglog:206
logImp(label, formatted, args);
^
TypeError <Object <Object <[Object: null prototype] {}>>>: logImp is not a function
at timeLogImpl (node:internal/util/debuglog:206:5)
at timeLog (node:internal/util/debuglog:313:5)
at console.timeLog (node:internal/console/constructor:423:5)
at Object.<anonymous> (/home/h4ad/Projects/opensource/node-copy-4/test/parallel/test-console-with-frozen-intrinsics.js:18:9)
Failed to start CI⚠ Something was pushed to the Pull Request branch since the last approving review. ℹ request-ci label was added by a Collaborator after the last push event. - Validating Jenkins credentials ✔ Jenkins credentials valid - Starting PR CI job ✘ Failed to start PR CI: 400 Bad Requesthttps://github.com/nodejs/node/actions/runs/10134591301 |
Commit Queue failed- Loading data for nodejs/node/pull/54070 ✔ Done loading data for nodejs/node/pull/54070 ----------------------------------- PR info ------------------------------------ Title console: fix issues with frozen intrinsics (#54070) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch H4ad:fix/frozen-intrinsics -> nodejs:main Labels console, author ready, needs-ci, commit-queue-squash Commits 2 - console: fix issues with frozen intrinsics - remove method that does not exist Committers 2 - Vinícius Lourenço <contact@viniciusl.com.br> - GitHub <noreply@github.com> PR-URL: https://github.com/nodejs/node/pull/54070 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/54070 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last approving review: ⚠ - remove method that does not exist ℹ This PR was created on Sat, 27 Jul 2024 16:14:40 GMT ✔ Approvals: 2 ✔ - Ruben Bridgewater (@BridgeAR) (TSC): https://github.com/nodejs/node/pull/54070#pullrequestreview-2203209471 ✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/54070#pullrequestreview-2203227532 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2024-07-29T21:15:24Z: https://ci.nodejs.org/job/node-test-pull-request/60731/ - Querying data for job/node-test-pull-request/60731/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/10153125854 |
Landed in 890760b |
PR-URL: #54070 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
PR-URL: #54070 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Fixes #54057
I also added a fix for
kGroupIndent
that was also broken for frozen intrinsics.