Skip to content
Open
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
12 changes: 12 additions & 0 deletions src/utils/deploy/hash-fns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ const hashFns = async (
statusCb,
tmpDir,
})

// ZISI's in-memory FunctionResult only nests bootstrap/runtime version into
// buildData when writing the manifest cache. Reconstruct it for direct-zip paths.
for (const func of functionZips) {
if (!func.buildData) {
func.buildData = {
bootstrapVersion: func.bootstrapVersion,
runtimeAPIVersion: func.runtimeAPIVersion,
}
}
}

const fileObjs = functionZips.map(
({
buildData,
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/utils/deploy/hash-fns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,31 @@ test('Hashes files in a folder', async (t) => {
})
})
})

test('Populates build_data.bootstrapVersion for v2 functions on direct-zip path', async (t) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withNetlifyToml({ config: { functions: { directory: 'functions' } } })
.withFunction({
path: 'hello.js',
runtimeAPIVersion: 2,
handler: (_req: Request) => new Response('Hello'),
})
.build()

const { fnConfig } = await hashFns(new BaseCommand(), [path.join(builder.directory, 'functions')], {
tmpDir: temporaryDirectory(),
concurrentHash: DEFAULT_CONCURRENT_HASH,
statusCb() {},
})

expect(fnConfig).toBeDefined()
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- covered by expectation above
const helloConfig = fnConfig!.hello as { build_data?: { bootstrapVersion?: string; runtimeAPIVersion?: number } }
expect(helloConfig).toBeDefined()
expect(helloConfig.build_data).toBeDefined()
expect(helloConfig.build_data?.runtimeAPIVersion).toBe(2)
expect(helloConfig.build_data?.bootstrapVersion).toEqual(expect.any(String))
expect(helloConfig.build_data?.bootstrapVersion).not.toBe('')
})
})
Loading