0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/message/console_low_stack_space.js
Anna Henningsen dab09877b0
module: don't cache uninitialized builtins
Don't cache the exported values of fully uninitialized builtins.
This works by adding an additional `loading` flag that is only
active during initial loading of an internal module and checking
that either the module is fully loaded or is in that state before
using its cached value.

This has the effect that builtins modules which could not be loaded
(e.g. because compilation failed due to missing stack space) can be
loaded at a later point.

Fixes: https://github.com/nodejs/node/issues/6899
PR-URL: https://github.com/nodejs/node/pull/6907
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-05-24 17:03:22 +02:00

23 lines
429 B
JavaScript

'use strict';
// copy console accessor because requiring ../common touches it
const consoleDescriptor = Object.getOwnPropertyDescriptor(global, 'console');
delete global.console;
global.console = {};
require('../common');
function a() {
try {
return a();
} catch (e) {
const console = consoleDescriptor.get();
if (console.log) {
console.log('Hello, World!');
} else {
throw e;
}
}
}
a();