Skip to content

Commit

Permalink
fix(runtime): fix #1229 init function invoke error (#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyoct authored Jun 7, 2023
1 parent 35847ee commit 928ee5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions runtimes/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import xmlparser from 'express-xml-bodyparser'
import './support/cloud-sdk'
import { FunctionCache } from './support/function-engine/cache'
import { DatabaseChangeStream } from './support/db-change-stream'
import { InitHook } from './support/init-hook'
import { ensureCollectionIndexes } from './support/function-log'

const app = express()
Expand All @@ -30,7 +29,6 @@ DatabaseAgent.accessor.ready.then(() => {
ensureCollectionIndexes()
FunctionCache.initialize()
DatabaseChangeStream.initialize()
InitHook.invoke()
})

if (process.env.NODE_ENV === 'development') {
Expand Down Expand Up @@ -73,8 +71,7 @@ app.use(function (req, res, next) {
if (req.url !== '/_/healthz') {
logger.info(
requestId,
`${req.method} "${req.url}" - referer: ${
req.get('referer') || '-'
`${req.method} "${req.url}" - referer: ${req.get('referer') || '-'
} ${req.get('user-agent')}`,
)
logger.trace(requestId, `${req.method} ${req.url}`, {
Expand Down
5 changes: 5 additions & 0 deletions runtimes/nodejs/src/support/function-engine/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ICloudFunctionData, RequireFuncType } from './types'
import { FunctionRequire } from './require'
import { logger } from '../logger'
import assert from 'assert'
import { InitHook } from '../init-hook'

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

this.streamChange()
logger.info('Function cache initialized.')

// invoke init function
InitHook.invoke()

}

/**
Expand Down

0 comments on commit 928ee5c

Please sign in to comment.