summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/console.js4
-rw-r--r--test/message/console_low_stack_space.js15
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/console.js b/lib/console.js
index 08a6cf4fa7..48343bc3e8 100644
--- a/lib/console.js
+++ b/lib/console.js
@@ -94,6 +94,10 @@ function write(ignoreErrors, stream, string, errorhandler) {
stream.write(string, errorhandler);
} catch (e) {
+ // console is a debugging utility, so it swallowing errors is not desirable
+ // even in edge cases such as low stack space.
+ if (e.message === 'Maximum call stack size exceeded')
+ throw e;
// Sorry, there’s no proper way to pass along the error here.
} finally {
stream.removeListener('error', noop);
diff --git a/test/message/console_low_stack_space.js b/test/message/console_low_stack_space.js
index 1685a35a1f..6b4ae8f479 100644
--- a/test/message/console_low_stack_space.js
+++ b/test/message/console_low_stack_space.js
@@ -6,13 +6,20 @@ global.console = {};
require('../common');
+// This test checks that, if Node cannot put together the `console` object
+// because it is low on stack space while doing so, it can succeed later
+// once the stack has unwound a little, and `console` is in a usable state then.
+
+let compiledConsole;
+
function a() {
try {
return a();
} catch (e) {
- const console = consoleDescriptor.get();
- if (console.log) {
- console.log('Hello, World!');
+ compiledConsole = consoleDescriptor.get();
+ if (compiledConsole.log) {
+ // Using `console.log` itself might not succeed yet, but the code for it
+ // has been compiled.
} else {
throw e;
}
@@ -20,3 +27,5 @@ function a() {
}
a();
+
+compiledConsole.log('Hello, World!');