Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
Merge commit '5782ec24273706dbacd669d36c14d89d78ea230b' into v4.5.0-p…
Browse files Browse the repository at this point in the history
…roposal-port
  • Loading branch information
richardlau committed Jul 14, 2016
2 parents db4b8f2 + 5782ec2 commit af6fa99
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@
this.id = id;
this.exports = {};
this.loaded = false;
this.loading = true;
}

NativeModule._source = process.binding('natives');
Expand All @@ -888,7 +889,7 @@
}

var cached = NativeModule.getCached(id);
if (cached) {
if (cached && (cached.loaded || cached.loading)) {
return cached.exports;
}

Expand Down Expand Up @@ -952,13 +953,18 @@
var source = NativeModule.getSource(this.id);
source = NativeModule.wrap(source);

var fn = runInThisContext(source, {
filename: this.filename,
lineOffset: 0
});
fn(this.exports, NativeModule.require, this, this.filename);
this.loading = true;
try {
var fn = runInThisContext(source, {
filename: this.filename,
lineOffset: 0
});
fn(this.exports, NativeModule.require, this, this.filename);

this.loaded = true;
this.loaded = true;
} finally {
this.loading = false;
}
};

NativeModule.prototype.cache = function() {
Expand Down
22 changes: 22 additions & 0 deletions test/message/console_low_stack_space.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'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();
1 change: 1 addition & 0 deletions test/message/console_low_stack_space.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!

0 comments on commit af6fa99

Please sign in to comment.