Skip to content

Commit ba378a6

Browse files
authored
fix(runtime): default close module cache (#1604)
1 parent 06cafd4 commit ba378a6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

runtimes/nodejs/src/config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,8 @@ export default class Config {
100100
static get OSS_EXTERNAL_ENDPOINT(): string {
101101
return process.env.OSS_EXTERNAL_ENDPOINT
102102
}
103+
104+
static get ENABLE_MODULE_CACHE(): boolean {
105+
return process.env.ENABLE_MODULE_CACHE === 'true' || false
106+
}
103107
}

runtimes/nodejs/src/support/engine/module.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Config from '../../config'
12
import { FunctionCache } from './cache'
23
import { FunctionContext } from './types'
34
import { buildSandbox, createScript } from './utils'
@@ -36,7 +37,9 @@ export class FunctionModule {
3637
)
3738

3839
// cache module
39-
FunctionModule.cache.set(name, functionModule)
40+
if (Config.ENABLE_MODULE_CACHE) {
41+
FunctionModule.cache.set(name, functionModule)
42+
}
4043
return functionModule
4144
}
4245
return require(name)

0 commit comments

Comments
 (0)