diff --git a/kits/firestore-genai-chatbot/src/config.ts b/kits/firestore-genai-chatbot/src/config.ts index fab3d2816..a60d64ac4 100644 --- a/kits/firestore-genai-chatbot/src/config.ts +++ b/kits/firestore-genai-chatbot/src/config.ts @@ -242,5 +242,8 @@ export function envDeployOptions(): DeployTimeOptions { // `.env`, the `{messageId}` wildcard stays literal (matches extension.yaml's // `${COLLECTION_NAME}/{messageId}` trigger resource). document: expr`${params.collectionName}/{messageId}`, + // extension.yaml sets `timeout: 540s`; without this the function takes + // the 60s default and long generations time out. + timeoutSeconds: 540, }; } diff --git a/kits/firestore-genai-chatbot/src/export-config.ts b/kits/firestore-genai-chatbot/src/export-config.ts index 6c71012e0..58560a9fe 100644 --- a/kits/firestore-genai-chatbot/src/export-config.ts +++ b/kits/firestore-genai-chatbot/src/export-config.ts @@ -127,6 +127,8 @@ export interface ResolvedGenaiChatbotConfig { export interface DeployTimeOptions { /** Watched Firestore document/collection path for the trigger. */ document: string | Expression; + /** Function timeout in seconds; extension.yaml sets `timeout: 540s`. */ + timeoutSeconds: number; } /** diff --git a/kits/firestore-genai-chatbot/src/index.ts b/kits/firestore-genai-chatbot/src/index.ts index f6e931b22..4b32a6045 100644 --- a/kits/firestore-genai-chatbot/src/index.ts +++ b/kits/firestore-genai-chatbot/src/index.ts @@ -86,6 +86,7 @@ export const generateMessage = onDocumentWritten( { document: deployOptions.document, secrets: [apiKeySecret], + timeoutSeconds: deployOptions.timeoutSeconds, }, (event) => handleDocumentWrite(event, getContext()) ); diff --git a/kits/firestore-genai-chatbot/tests/deploy-options.test.ts b/kits/firestore-genai-chatbot/tests/deploy-options.test.ts index 605f52285..c74576b04 100644 --- a/kits/firestore-genai-chatbot/tests/deploy-options.test.ts +++ b/kits/firestore-genai-chatbot/tests/deploy-options.test.ts @@ -45,6 +45,10 @@ describe("envDeployOptions", () => { expect(options).not.toHaveProperty("region"); }); + test("declares the extension's 540s timeout", () => { + expect(options.timeoutSeconds).toBe(540); + }); + test("document expression is not a frozen undefined/empty literal", () => { expect(options.document).toBeInstanceOf(Expression); expect(cel(options.document)).not.toContain("undefined");