diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-02-22 18:52:38 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-01 12:27:15 +0100 |
commit | 410eb97bcea9bf8fb15c1b980a19c3a8daaa6824 (patch) | |
tree | 13c8d8e9a09bf82f0effde02d8c1e2a4af3f9f98 /test | |
parent | 3fce5cf439cea1808e8984640638aac5c2b08b12 (diff) | |
download | android-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 'test')
-rw-r--r-- | test/fixtures/module-require-depth/one.js | 11 | ||||
-rw-r--r-- | test/fixtures/module-require-depth/two.js | 11 | ||||
-rw-r--r-- | test/parallel/test-module-require-depth.js | 16 |
3 files changed, 0 insertions, 38 deletions
diff --git a/test/fixtures/module-require-depth/one.js b/test/fixtures/module-require-depth/one.js deleted file mode 100644 index 02b451465b..0000000000 --- a/test/fixtures/module-require-depth/one.js +++ /dev/null @@ -1,11 +0,0 @@ -// Flags: --expose_internals -'use strict'; -const assert = require('assert'); -const { - requireDepth -} = require('internal/modules/cjs/helpers'); - -exports.requireDepth = requireDepth; -assert.strictEqual(requireDepth, 1); -assert.deepStrictEqual(require('./two'), { requireDepth: 2 }); -assert.strictEqual(requireDepth, 1); diff --git a/test/fixtures/module-require-depth/two.js b/test/fixtures/module-require-depth/two.js deleted file mode 100644 index 5c94c4c89a..0000000000 --- a/test/fixtures/module-require-depth/two.js +++ /dev/null @@ -1,11 +0,0 @@ -// Flags: --expose_internals -'use strict'; -const assert = require('assert'); -const { - requireDepth -} = require('internal/modules/cjs/helpers'); - -exports.requireDepth = requireDepth; -assert.strictEqual(requireDepth, 2); -assert.deepStrictEqual(require('./one'), { requireDepth: 1 }); -assert.strictEqual(requireDepth, 2); diff --git a/test/parallel/test-module-require-depth.js b/test/parallel/test-module-require-depth.js deleted file mode 100644 index 0a3fc2826c..0000000000 --- a/test/parallel/test-module-require-depth.js +++ /dev/null @@ -1,16 +0,0 @@ -// Flags: --expose_internals -'use strict'; -require('../common'); -const fixtures = require('../common/fixtures'); -const assert = require('assert'); -const { - requireDepth -} = require('internal/modules/cjs/helpers'); - -// Module one loads two too so the expected depth for two is, well, two. -assert.strictEqual(requireDepth, 0); -const one = require(fixtures.path('module-require-depth', 'one')); -const two = require(fixtures.path('module-require-depth', 'two')); -assert.deepStrictEqual(one, { requireDepth: 1 }); -assert.deepStrictEqual(two, { requireDepth: 2 }); -assert.strictEqual(requireDepth, 0); |