Luis
Luisthis hour

The default Firebase app already exists

I have the following Flow: 1. Inputs 2. Switch based on one of the inputs 2.1. Condition 1: 'Execute BuildShip Workflow' pointing to a 2nd Flow 2.2. Fallback 3. Flow Output The first time I execute it, the Flow Output returns the 2nd Flow output as expected. After that, the 2nd Flow fails and its Firestore Collection Query node returns: "The default Firebase app already exists. This means you called initializeApp() more than once without providing an app name as the second argument. In most cases, you only need to call initializeApp() once. But if you do want to initialize multiple apps, pass a second argument to initializeApp() to give each app a unique name." I tried adding a BuildShip Workflow Trigger to the 2nd Flow but now I think it's unnecessary since both flows are in the same workflow. I found out that's a Firestore issue. There's plenty of documentation about how to solve it when you have your own code, but I don't know how to solve it from BuildShip. I miss there's no BuildShip documentation about the Execute BuildShip Workflow node. #firestoreIssue #ExecuteBuildShipWorkflowNodeIssue
Solution:
Hi @Luis on the share flow via suppot request, you are using a custom-created Firestore Collection Query node, which has the issue in the node logic, you are initializing the App with firebasae-admin/app each time the filterFiresoreDocs function is executed. The app should not be initialized more than once. We already have a node for the collection query, I recommend you use the library node instead, which is using the google-cloud/firestore, to avoid this issue, you can modify it with AI to add...
Jump to solution
4 Replies
AI Support
AI Supportthis hour
AI Support Bot Information
<@1026190854693605436> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human! Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers. Please note: Team members will review and answer the questions on best efforts basis.
AI Support
AI Supportthis hour
AI Response
It seems that there is no specific node called "Execute BuildShip Workflow" within the current BuildShip nodes database that directly relates to your issue. However, it is possible that there may be a custom solution within BuildShip for invoking a workflow from another workflow. Regarding the Firestore issue you described, the error typically occurs when initializeApp() is called multiple times with the default app configuration. In BuildShip, Firestore is often managed through preconfigured nodes and does not require explicit app initialization in your workflows. Here's how you might resolve this issue: 1. Check Firestore Node Usage: Ensure that you are not explicitly initializing Firestore in the second flow if it is already done in the first flow. 2. Node Configuration: If you have a custom script node or any form of custom code, ensure that initializeApp() is not called repeatedly without passing a unique app identifier if needed. 3. Separate Workflow: If executing workflows within workflows, verify that the second flow (workflow) does not duplicate the database initialization if called multiple times from the main one. 4. BuildShip Support: As this might need deeper investigation into the specific nodes and configuration you are using, it could be beneficial to contact BuildShip support for guidance tailored to your application's structure. Unfortunately, the documentation about the "Execute BuildShip Workflow" node specifically is not available. I recommend reaching out to BuildShip support directly for further assistance on this specific integration within your current setup if the above resolutions do not solve your issue.
BuildShip AI Support
Solution
Gaurav Chadha
Gaurav Chadha17h ago
Hi @Luis on the share flow via suppot request, you are using a custom-created Firestore Collection Query node, which has the issue in the node logic, you are initializing the App with firebasae-admin/app each time the filterFiresoreDocs function is executed. The app should not be initialized more than once. We already have a node for the collection query, I recommend you use the library node instead, which is using the google-cloud/firestore, to avoid this issue, you can modify it with AI to add an input for the array to query. Sent you an email as well.
Luis
LuisOP17h ago
Thank you. I saw your email and that was the solution. I updated the beginning of that node adding:
import { initializeApp, getApps } from 'firebase-admin/app'; import { getFirestore } from 'firebase-admin/firestore';
And added this later:
// Initialize Firestore only if no apps are initialized let firebaseApp; if (!getApps().length) { firebaseApp = initializeApp({ projectId }); } else { firebaseApp = getApps()[0]; // Use the existing app } const firestore = getFirestore(firebaseApp);

Did you find this page helpful?