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

console: fix issues with frozen intrinsics #54070

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

H4ad
Copy link
Member

@H4ad H4ad commented Jul 27, 2024

Fixes #54057

I also added a fix for kGroupIndent that was also broken for frozen intrinsics.

@nodejs-github-bot nodejs-github-bot added console Issues and PRs related to the console subsystem. needs-ci PRs that need a full CI run. labels Jul 27, 2024
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);
Copy link
Member

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.

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 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)

@H4ad H4ad added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 27, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 27, 2024
@nodejs-github-bot
Copy link
Collaborator

@H4ad H4ad added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2024
@github-actions github-actions bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jul 28, 2024
Copy link
Contributor

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 Request
https://github.com/nodejs/node/actions/runs/10134591301

@jakecastelli jakecastelli added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. labels Jul 29, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 29, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@H4ad H4ad added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jul 29, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 29, 2024
@nodejs-github-bot
Copy link
Collaborator

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 <[email protected]>
 - GitHub <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/54070
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/54070
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
--------------------------------------------------------------------------------
   ⚠  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/.ncu
https://github.com/nodejs/node/actions/runs/10153125854

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Jul 29, 2024
@jakecastelli jakecastelli added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jul 30, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 30, 2024
@nodejs-github-bot nodejs-github-bot merged commit 890760b into nodejs:main Jul 30, 2024
68 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 890760b

targos pushed a commit that referenced this pull request Jul 30, 2024
PR-URL: #54070
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Jake Yuesong Li <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Jul 30, 2024
RafaelGSS pushed a commit that referenced this pull request Aug 5, 2024
PR-URL: #54070
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Jake Yuesong Li <[email protected]>
@targos targos added the dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. console Issues and PRs related to the console subsystem. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

console.timeEnd and console.timeLog throw when using --frozen-intrinsics
6 participants