Skip to content

Commit

Permalink
fix(runtime): default close module cache (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyoct authored Oct 24, 2023
1 parent 06cafd4 commit ba378a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions runtimes/nodejs/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ export default class Config {
static get OSS_EXTERNAL_ENDPOINT(): string {
return process.env.OSS_EXTERNAL_ENDPOINT
}

static get ENABLE_MODULE_CACHE(): boolean {
return process.env.ENABLE_MODULE_CACHE === 'true' || false
}
}
5 changes: 4 additions & 1 deletion runtimes/nodejs/src/support/engine/module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Config from '../../config'
import { FunctionCache } from './cache'
import { FunctionContext } from './types'
import { buildSandbox, createScript } from './utils'
Expand Down Expand Up @@ -36,7 +37,9 @@ export class FunctionModule {
)

// cache module
FunctionModule.cache.set(name, functionModule)
if (Config.ENABLE_MODULE_CACHE) {
FunctionModule.cache.set(name, functionModule)
}
return functionModule
}
return require(name)
Expand Down

0 comments on commit ba378a6

Please sign in to comment.