Skip to content

Commit 928ee5c

Browse files
authored
fix(runtime): fix #1229 init function invoke error (#1230)
1 parent 35847ee commit 928ee5c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

runtimes/nodejs/src/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import xmlparser from 'express-xml-bodyparser'
2121
import './support/cloud-sdk'
2222
import { FunctionCache } from './support/function-engine/cache'
2323
import { DatabaseChangeStream } from './support/db-change-stream'
24-
import { InitHook } from './support/init-hook'
2524
import { ensureCollectionIndexes } from './support/function-log'
2625

2726
const app = express()
@@ -30,7 +29,6 @@ DatabaseAgent.accessor.ready.then(() => {
3029
ensureCollectionIndexes()
3130
FunctionCache.initialize()
3231
DatabaseChangeStream.initialize()
33-
InitHook.invoke()
3432
})
3533

3634
if (process.env.NODE_ENV === 'development') {
@@ -73,8 +71,7 @@ app.use(function (req, res, next) {
7371
if (req.url !== '/_/healthz') {
7472
logger.info(
7573
requestId,
76-
`${req.method} "${req.url}" - referer: ${
77-
req.get('referer') || '-'
74+
`${req.method} "${req.url}" - referer: ${req.get('referer') || '-'
7875
} ${req.get('user-agent')}`,
7976
)
8077
logger.trace(requestId, `${req.method} ${req.url}`, {

runtimes/nodejs/src/support/function-engine/cache.ts

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ICloudFunctionData, RequireFuncType } from './types'
44
import { FunctionRequire } from './require'
55
import { logger } from '../logger'
66
import assert from 'assert'
7+
import { InitHook } from '../init-hook'
78

89
export class FunctionCache {
910
private static cache: Map<string, ICloudFunctionData> = new Map()
@@ -21,6 +22,10 @@ export class FunctionCache {
2122

2223
this.streamChange()
2324
logger.info('Function cache initialized.')
25+
26+
// invoke init function
27+
InitHook.invoke()
28+
2429
}
2530

2631
/**

0 commit comments

Comments
 (0)