Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix init function invoke error #1230

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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