forked from nodejs/node
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not cache modules that throw exceptions
If a module throws an exception on load, it should not be cached. This patch shows the problem in a test case and also fixes it. See: https://groups.google.com/forum/#!topic/nodejs-dev/1cIrvJcADbY Closes nodejsGH-707 Closes nodejsGH-710
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
// A module with an error in it should throw | ||
assert.throws(function() { | ||
require(common.fixturesDir + '/throws_error'); | ||
}); | ||
|
||
// Requiring the same module again should throw as well | ||
assert.throws(function() { | ||
require(common.fixturesDir + '/throws_error'); | ||
}); |