You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
console.timeEnd and console.timeLog throw when using --frozen-intrinsics #54057
How often does it reproduce? Is there a required condition?
This always reproduces as far as I can tell. It is caused by the console.timeEnd / console.timeLog implementation
What is the expected behavior? Why is that the expected behavior?
Expected behavior is what happens when running without --frozen-intrinsics:
$ node demo.js
bunch-of-stuff: 0.061ms
What do you see instead?
$ node --frozen-intrinsics demo.js
node:internal/console/constructor:418
this[kInternalTimeLogImpl] = FunctionPrototypeBind(timeLogImpl, this);
^
TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot add property Symbol(kInternalTimeLogImpl), object is not extensible
at console.timeLog (node:internal/console/constructor:418:34)
at Object.<anonymous> (/home/jfhr/source/demo.js:2:9)
at Module._compile (node:internal/modules/cjs/loader:1504:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1588:10)
at Module.load (node:internal/modules/cjs/loader:1282:32)
at Module._load (node:internal/modules/cjs/loader:1098:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)
at node:internal/main/run_main_module:30:49
Node.js v22.5.1
Additional information
The first call to console.timeEnd / console.timeLog tries to write to this[kInternalTimeLogImpl] (see console/constructor.js) which fails if this is frozen. This property stores the timeLog implementation that is passed to util/debuglog.
Perhaps a WeakMap could be used to store the timeLog implementation instead of a writable private property?
Activity
jakecastelli commentedon Jul 26, 2024
Introduced in
v22.3.0. Points to this commit f883865 cc @H4ad 👀H4ad commentedon Jul 26, 2024
Thanks for the report, I will open a PR soon.
jfhr commentedon Jul 30, 2024
thank you for the fix @H4ad !