Skip to content

Commit 544c602

Browse files
joyeecheungaduh95
authored andcommitted
module: skip NODE_COMPILE_CACHE when policy is enabled
It might be worth designing a policy for the compilation cache. For now, just skip the cache when policy is enabled. PR-URL: #52577 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 4f713fb commit 544c602

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎src/env.cc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,12 @@ void Environment::InitializeCompileCache() {
10961096
dir_from_env.empty()) {
10971097
return;
10981098
}
1099+
if (!options()->experimental_policy.empty()) {
1100+
Debug(this,
1101+
DebugCategory::COMPILE_CACHE,
1102+
"[compile cache] skipping cache because policy is enabled");
1103+
return;
1104+
}
10991105
auto handler = std::make_unique<CompileCacheHandler>(this);
11001106
if (handler->InitializeDirectory(this, dir_from_env)) {
11011107
compile_cache_handler_ = std::move(handler);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
// This tests NODE_COMPILE_CACHE is disabled when policy is used.
4+
5+
constcommon=require('../common');
6+
if(!common.hasCrypto)
7+
common.skip('missing crypto');
8+
9+
const{ spawnSyncAndAssert }=require('../common/child_process');
10+
constassert=require('assert');
11+
constfs=require('fs');
12+
consttmpdir=require('../common/tmpdir');
13+
constfixtures=require('../common/fixtures');
14+
15+
{
16+
tmpdir.refresh();
17+
constdir=tmpdir.resolve('.compile_cache_dir');
18+
constscript=fixtures.path('policy','parent.js');
19+
constpolicy=fixtures.path(
20+
'policy',
21+
'dependencies',
22+
'dependencies-redirect-policy.json');
23+
spawnSyncAndAssert(
24+
process.execPath,
25+
['--experimental-policy',policy,script],
26+
{
27+
env: {
28+
...process.env,
29+
NODE_DEBUG_NATIVE: 'COMPILE_CACHE',
30+
NODE_COMPILE_CACHE: dir
31+
},
32+
cwd: tmpdir.path
33+
},
34+
{
35+
stderr: /skippingcachebecausepolicyisenabled/
36+
});
37+
assert(!fs.existsSync(dir));
38+
}

0 commit comments

Comments
 (0)