GenkitG
Genkit•13mo ago
thick-teal

I have a firebase function gen 1 that

I have a firebase function gen 1 that calls a genkit flow. Pre the 0.5 upgrade, it was working fine. Now, when I try to trigger the gen 1 http function, I get this:
"TypeError: Cannot read properties of undefined (reading 'headers')
    at /workspace/node_modules/firebase-functions/lib/v2/trace.js:12:68
    at /workspace/lib/reviews.js:46:26
    at /workspace/node_modules/firebase-functions/lib/common/onInit.js:33:16
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at /workspace/node_modules/firebase-functions/lib/v2/trace.js:18:37
    at cloudFunction (/workspace/node_modules/firebase-functions/lib/v1/providers/https.js:53:78)
    at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:100:29
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)"

My gen 1 http firebase function is this:
exports.testReview = functions.https.onRequest(async (req, res) => {
  console.log("running testReview");
  const response = await testFlow().output;
  console.log(`response: ${response}`);
  return res.send(response);
});

And my flow is this:
export const testFlow = onFlow(
  ai,
  {
    name: "testFlow",
    outputSchema: z.string(),
    enforceAppCheck: false,
    // Auth is enforced by Cloud IAM
    authPolicy: noAuth(),
    httpsOptions: {
      memory: "512MiB",
      // minInstances: 1,
      timeoutSeconds: 120,
    },
  },
  async () => {
    const llmResponse = await ai.generate({
      model: gpt4o,
      prompt: "Tell me a joke about the weather.",
      config: {
        temperature: 0.7,
      },
    });

    const text = llmResponse.text;
    console.log(text);

    return text;
  },
);

Any ideas on what changed with the upgrade that's causing my issue?
Was this page helpful?