GenkitG
Genkitโ€ข14mo agoโ€ข
5 replies
abstract-purple

Team - I'm encountering an issue

Team - I'm encountering an issue integrating Genkit flows with my existing Firebase Functions (V1) project. Here's my situation:

1. What's Working:
- My Genkit flows work perfectly in the Genkit UI
- I can successfully trigger flows directly from the terminal
- The flow itself (shortStoryFlowWithSchema) functions as expected when called directly

2. The Problem:
- When trying to call the flow through my API endpoint (Firebase Function V1), I get this error:
   TypeError: Cannot read properties of undefined (reading 'on')

- This occurs in: firebase-functions/lib/v2/providers/https.js

3. Project Setup:
- Existing Firebase Functions project using V1
- Genkit flow using onFlow from @genkit-ai/firebase/functions
- Using .mjs extension for all Genkit-related files
- Main API controller files are in CommonJS (.js)
- Using dynamic import bridge to connect ES Modules and CommonJS:
```javascript exports.generateStory = async (...args) => { const { generateStory } = await import("./generateStory.mjs"); return generateStory(...args); };
```
4. Questions:
- Is there a simpler solution to integrate Genkit flows with Firebase Functions V1?
- If not, do I need to create a separate Firebase Functions project using V2 specifically for Genkit flows? Would the recommended architecture be to have:
- V1 Functions project for existing endpoints
- V2 Functions project for Genkit flows
- Communication between them via API calls?

Any pointers? Love you turkeys! Thanks ๐Ÿ™‚
Was this page helpful?