mirror of https://github.com/nodejs/node.git
Fix: require.async module exception delegation
The fs.readFile bug was hiding another bug that was causing this test to pass, even so it was broken: require.async("../fixtures/throws_error1") in test-module-loading.js This patch fixes the original test by running _compile within a try..catch block for _loadScript. _loadScriptSync also had some useless (deprecated?) code for dealing with module entry point exceptions. This code was also removed for greater clarity.
This commit is contained in:
parent
55e964ec19
commit
987cbe35c6
|
@ -390,12 +390,8 @@ Module.prototype._compile = function (content, filename) {
|
|||
|
||||
Module.prototype._loadScriptSync = function (filename) {
|
||||
var content = requireNative('fs').readFileSync(filename, 'utf8');
|
||||
var e = this._compile(content, filename);
|
||||
if (e) {
|
||||
throw e;
|
||||
} else {
|
||||
this.loaded = true;
|
||||
}
|
||||
this._compile(content, filename);
|
||||
this.loaded = true;
|
||||
};
|
||||
|
||||
|
||||
|
@ -406,16 +402,18 @@ Module.prototype._loadScript = function (filename, callback) {
|
|||
if (err) {
|
||||
if (callback) callback(err);
|
||||
} else {
|
||||
var e = self._compile(content, filename);
|
||||
if (e) {
|
||||
if (callback) callback(e);
|
||||
} else {
|
||||
self._waitChildrenLoad(function () {
|
||||
self.loaded = true;
|
||||
if (self.onload) self.onload();
|
||||
if (callback) callback(null, self.exports);
|
||||
});
|
||||
try {
|
||||
self._compile(content, filename);
|
||||
} catch (err) {
|
||||
if (callback) callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
self._waitChildrenLoad(function () {
|
||||
self.loaded = true;
|
||||
if (self.onload) self.onload();
|
||||
if (callback) callback(null, self.exports);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue