From 1c96ed816abaf5d2735f13dc61a667eed67b968c Mon Sep 17 00:00:00 2001 From: Netlify Bot Date: Fri, 29 May 2026 11:19:36 +0100 Subject: [PATCH 1/2] feat: add support for new function config properties --- src/lib/functions/netlify-function.ts | 23 +++++++++++++++---- src/lib/functions/runtimes/index.ts | 1 + .../functions/runtimes/js/builders/zisi.ts | 3 +++ src/utils/deploy/hash-fns.ts | 13 ++++++++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/lib/functions/netlify-function.ts b/src/lib/functions/netlify-function.ts index baf87fb3a13..669ced4dda0 100644 --- a/src/lib/functions/netlify-function.ts +++ b/src/lib/functions/netlify-function.ts @@ -64,9 +64,24 @@ export default class NetlifyFunction { // main file. public readonly srcPath: string - // Determines whether this is a background function based on the function - // name. - public readonly isBackground: boolean + // Determines whether this is a background function. Checks (in order): + // 1. ZISI build data — `invocationMode === 'background'` captures the + // filename suffix AND the in-source `config.background: true`. + // 2. The TOML config — `[functions.] background = true`. + // 3. The filename suffix as a last-resort fallback (used pre-build and for + // non-ZISI runtimes like Go). + get isBackground(): boolean { + if (this.buildData?.invocationMode === 'background') { + return true + } + + // TODO; Update the type and cut a new version of `@netlify/config`. + // @ts-expect-error -- `background` is missing from `FunctionsObject` in `@netlify/build/lib/types/config/functions.d.ts`; remove once that type is updated and the dep is bumped. + if (this.config.functions?.[this.name]?.background === true) { + return true + } + return this.name.endsWith(BACKGROUND) + } private buildQueue?: Promise | undefined public buildData?: MappedOmit | undefined @@ -123,8 +138,6 @@ export default class NetlifyFunction { this.settings = settings this.srcPath = srcPath - this.isBackground = name.endsWith(BACKGROUND) - const functionConfig = config.functions?.[name] // @ts-expect-error -- XXX(serhalp): fixed in stack PR (bumps to https://github.com/netlify/build/pull/6165) this.schedule = functionConfig && functionConfig.schedule diff --git a/src/lib/functions/runtimes/index.ts b/src/lib/functions/runtimes/index.ts index cd8c7bdfa0d..eaa9dd4f19f 100644 --- a/src/lib/functions/runtimes/index.ts +++ b/src/lib/functions/runtimes/index.ts @@ -21,6 +21,7 @@ export type BaseBuildResult = { // TODO(serhalp): This module and type shouldn't know about these zisi types. Refactor to allow the JS runtime's zisi // builder to define this on its extended base build result type. excludedRoutes?: Route[] | undefined + invocationMode?: string | undefined routes?: ExtendedRoute[] | undefined runtimeAPIVersion?: number | undefined } diff --git a/src/lib/functions/runtimes/js/builders/zisi.ts b/src/lib/functions/runtimes/js/builders/zisi.ts index 606cd906225..83d471f37db 100644 --- a/src/lib/functions/runtimes/js/builders/zisi.ts +++ b/src/lib/functions/runtimes/js/builders/zisi.ts @@ -23,6 +23,7 @@ const require = createRequire(import.meta.url) export type ZisiBuildResult = BaseBuildResult & { buildPath: string includedFiles: FunctionResult['includedFiles'] + invocationMode: FunctionResult['invocationMode'] outputModuleFormat: FunctionResult['outputModuleFormat'] mainFile: FunctionResult['mainFile'] runtimeAPIVersion: FunctionResult['runtimeAPIVersion'] @@ -66,6 +67,7 @@ const buildFunction = async ({ excludedRoutes, includedFiles, inputs, + invocationMode, mainFile, outputModuleFormat, path: functionPath, @@ -103,6 +105,7 @@ const buildFunction = async ({ buildPath, excludedRoutes, includedFiles, + invocationMode, outputModuleFormat, mainFile, routes, diff --git a/src/utils/deploy/hash-fns.ts b/src/utils/deploy/hash-fns.ts index d025710d9d2..c9edc6379a3 100644 --- a/src/utils/deploy/hash-fns.ts +++ b/src/utils/deploy/hash-fns.ts @@ -187,7 +187,15 @@ const hashFns = async ( const fnConfig = functionZips .filter((func) => Boolean( - func.displayName || func.generator || func.routes || func.buildData || func.priority || func.trafficRules, + func.displayName || + func.generator || + func.routes || + func.buildData || + func.priority || + func.trafficRules || + func.region || + func.memory || + func.vcpu, ), ) .reduce( @@ -197,10 +205,13 @@ const hashFns = async ( display_name: curr.displayName, excluded_routes: curr.excludedRoutes, generator: curr.generator, + memory: curr.memory, + region: curr.region, routes: curr.routes, build_data: curr.buildData, priority: curr.priority, traffic_rules: trafficRulesConfig(curr.trafficRules), + vcpu: curr.vcpu, }, }), {}, From 5e448560a768992ebe6837bd7fb7e2c373f8f845 Mon Sep 17 00:00:00 2001 From: Netlify Bot Date: Fri, 29 May 2026 11:20:45 +0100 Subject: [PATCH 2/2] update comment --- src/lib/functions/netlify-function.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/functions/netlify-function.ts b/src/lib/functions/netlify-function.ts index 669ced4dda0..b7880d08b03 100644 --- a/src/lib/functions/netlify-function.ts +++ b/src/lib/functions/netlify-function.ts @@ -75,8 +75,7 @@ export default class NetlifyFunction { return true } - // TODO; Update the type and cut a new version of `@netlify/config`. - // @ts-expect-error -- `background` is missing from `FunctionsObject` in `@netlify/build/lib/types/config/functions.d.ts`; remove once that type is updated and the dep is bumped. + // @ts-expect-error TODO; Update the type and cut a new version of `@netlify/config`. if (this.config.functions?.[this.name]?.background === true) { return true }