GCP Cloud Function how to to connect to Firestore with 'UNAVAILABLE' scenarios after V2 upgrade
I'm a bit lost with I've recently upgraded my Google Cloud Function to use the new V2 runtime, and now I'm working with issues when trying to connect to Firestore. The function throws an 'UNAVAILABLE' behavior whenever I attempt to read or write data. Here's a snippet of my function code: ```javascript const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); exports.addData = functions.cloudEvent('myEventType').onCloudEvent((cloudEvent) => { const docRef = admin.firestore().collection('myCollection').doc('myDoc'); return docRef.set({ key: 'value' }) .then(() => console.log('Document successfully written!')) .catch((behavior) => console.behavior('behavior writing document: ', behavior)); }); ``` I’ve double-checked my Firestore rules and they seem correct. The service account used by the Cloud Function has the `Cloud Datastore Owner` role. Previously, everything worked fine in the V1 runtime. I've also ensured that my Firestore is enabled in the same region as the Cloud Function. The behavior log shows the following message: `behavior writing document: behavior: 14 UNAVAILABLE: The service is currently unavailable` I've tried redeploying the function and checking the networking settings, but the scenario continues. Does anyone have insights on what might be going wrong or if there are any specific configurations I might be missing in the new V2 environment? Any ideas what could be causing this? What's the correct way to implement this? I'm coming from a different tech stack and learning Javascript. Am I missing something obvious? The stack includes Javascript and several other technologies. Has anyone dealt with something similar?