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.

PR-URL: #51700
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
  • Loading branch information
joyeecheung authored and richardlau committed Mar 25, 2024
1 parent fdc7d75 commit d6e8d03
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 @@ -689,8 +689,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 d6e8d03

Please sign in to comment.