Skip to content

Commit

Permalink
lib: create global console properties at snapshot build time
Browse files Browse the repository at this point in the history
It is safe to create the console properties for the global
console at snapshot build time. Streams must still be created
lazily however because they need special synchronization for
the handles.
  • Loading branch information
joyeecheung committed Feb 13, 2024
1 parent 9448c61 commit 7776e19
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,6 @@ Console.prototype.groupCollapsed = Console.prototype.group;

function initializeGlobalConsole(globalConsole) {
globalConsole[kBindStreamsLazy](process);
globalConsole[kBindProperties](true, 'auto');

const {
namespace: {
addSerializeCallback,
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/console/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {

const {
Console,
kBindProperties,
} = require('internal/console/constructor');

const globalConsole = { __proto__: {} };
Expand All @@ -41,6 +42,8 @@ for (const prop of ReflectOwnKeys(Console.prototype)) {
ReflectDefineProperty(globalConsole, prop, desc);
}

globalConsole[kBindProperties](true, 'auto');

// This is a legacy feature - the Console constructor is exposed on
// the global console instance.
globalConsole.Console = Console;
Expand Down

0 comments on commit 7776e19

Please sign in to comment.