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

tools, lib: fix console intrinsic freezing #46044

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/.eslintrc.yaml
Expand Up @@ -153,7 +153,7 @@ rules:
- name: clearTimeout
message: Use `const { clearTimeout } = require('timers');` instead of the global.
- name: console
message: Use `const { console } = require('internal/console/global');` instead of the global.
message: Use `const console = require('internal/console/global');` instead of the global.
- name: crypto
message: Use `const { crypto } = require('internal/crypto/webcrypto');` instead of the global.
- name: Crypto
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/freeze_intrinsics.js
Expand Up @@ -135,7 +135,7 @@ const {

module.exports = function() {
const { Console } = require('internal/console/constructor');
const { console } = require('internal/console/global');
anonrig marked this conversation as resolved.
Show resolved Hide resolved
const console = require('internal/console/global');
const {
clearImmediate,
clearInterval,
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-freeze-intrinsics.js
Expand Up @@ -37,3 +37,12 @@ assert.throws(
{ name: 'TypeError' });
assert.strictEqual(globalThis.globalThis, globalThis);
}

// Ensure that we cannot override console properties.
{
const { log } = console;

assert.throws(() => { console.log = null; },
{ name: 'TypeError' });
assert.strictEqual(console.log, log);
}