summaryrefslogtreecommitdiff
path: root/lib/internal/modules/cjs/helpers.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-02-22 18:52:38 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-01 12:27:15 +0100
commit410eb97bcea9bf8fb15c1b980a19c3a8daaa6824 (patch)
tree13c8d8e9a09bf82f0effde02d8c1e2a4af3f9f98 /lib/internal/modules/cjs/helpers.js
parent3fce5cf439cea1808e8984640638aac5c2b08b12 (diff)
downloadandroid-node-v8-410eb97bcea9bf8fb15c1b980a19c3a8daaa6824.tar.gz
android-node-v8-410eb97bcea9bf8fb15c1b980a19c3a8daaa6824.tar.bz2
android-node-v8-410eb97bcea9bf8fb15c1b980a19c3a8daaa6824.zip
module: fix stat cache
The current caching logic broke by [0] because it used destructuring on the module arguments. Since the exported property is a primitive counting it up or down would not have any effect anymore in the module that required that property. The original implementation would cache all stat calls caused during bootstrap. Afterwards it would clear the cache and lazy require calls during runtime would create a new cascading cache for the then loaded modules and clear the cache again. This behavior is now restored. This is difficult to test without exposing a lot of information and therfore the existing tests have been removed (as they could not detect the issue). With the broken implementation it caused each module compilation to reset the cache and therefore minimizing the effect drastically. [0] https://github.com/nodejs/node/pull/19177 PR-URL: https://github.com/nodejs/node/pull/26266 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/modules/cjs/helpers.js')
-rw-r--r--lib/internal/modules/cjs/helpers.js8
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js
index 874805becc..df727ff3c8 100644
--- a/lib/internal/modules/cjs/helpers.js
+++ b/lib/internal/modules/cjs/helpers.js
@@ -11,12 +11,7 @@ function makeRequireFunction(mod) {
const Module = mod.constructor;
function require(path) {
- try {
- exports.requireDepth += 1;
- return mod.require(path);
- } finally {
- exports.requireDepth -= 1;
- }
+ return mod.require(path);
}
function resolve(request, options) {
@@ -139,7 +134,6 @@ module.exports = exports = {
builtinLibs,
makeRequireFunction,
normalizeReferrerURL,
- requireDepth: 0,
stripBOM,
stripShebang
};