From e99ae7764d9fe77fb7ecadc180c55664ebfd4f19 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 16 Dec 2017 04:29:40 -0200 Subject: [PATCH] lib: make console writable and non-enumerable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the standard the property descriptor of console should be writable and non-enumerable. PR-URL: https://github.com/nodejs/node/pull/17708 Fixes: https://github.com/nodejs/node/issues/11805 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Matteo Collina Reviewed-By: Anatoli Papirovski --- lib/internal/bootstrap_node.js | 6 ++---- test/message/console_low_stack_space.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 20b038bae87..b11f5901a17 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -321,10 +321,8 @@ const wrappedConsole = NativeModule.require('console'); Object.defineProperty(global, 'console', { configurable: true, - enumerable: true, - get() { - return wrappedConsole; - } + enumerable: false, + value: wrappedConsole }); setupInspector(originalConsole, wrappedConsole, Module); } diff --git a/test/message/console_low_stack_space.js b/test/message/console_low_stack_space.js index 6b4ae8f479c..9128eb49d12 100644 --- a/test/message/console_low_stack_space.js +++ b/test/message/console_low_stack_space.js @@ -16,7 +16,7 @@ function a() { try { return a(); } catch (e) { - compiledConsole = consoleDescriptor.get(); + compiledConsole = consoleDescriptor.value; if (compiledConsole.log) { // Using `console.log` itself might not succeed yet, but the code for it // has been compiled.