CodexBloom - Programming Q&A Platform

GCP Cloud Functions scenarios to trigger on Firestore document changes despite correct config

๐Ÿ‘€ Views: 60 ๐Ÿ’ฌ Answers: 1 ๐Ÿ“… Created: 2025-06-08
google-cloud-functions firestore firebase cloud-functions JavaScript

I'm trying to figure out I've encountered a strange issue with I keep running into I'm working with an scenario where my GCP Cloud Function is not triggering as expected when a Firestore document is created or updated. I've set up the function to listen to changes in a specific collection, but it seems to be completely silent. Hereโ€™s the relevant part of my setup: ```javascript const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); exports.onDocumentChange = functions.firestore.document('myCollection/{docId}') .onWrite((change, context) => { console.log('Document changed:', change.after.data()); return null; }); ``` I deployed the function using the command `firebase deploy --only functions:onDocumentChange` and received a success message. The function's logs show that it was deployed correctly, but I'm not seeing any entries in the logs when I make changes to documents in `myCollection`. I've verified that Firestore rules allow read/write access and that the function has the necessary permissions. I also checked the Firestore triggers section in the GCP console, and it indicates that the trigger is active. To debug this, I tried adding a Cloud Scheduler job to trigger the function manually, and it worked fine, so the scenario seems specifically tied to the Firestore events. I'm currently using Firebase Functions SDK version 3.20.1 and Firestore version 8.6.8. I've tried redeploying the function and even created a new function with a different name, but it still doesnโ€™t trigger on document changes. Could there be something I'm missing in the configuration, or is there a known scenario with Cloud Functions and Firestore triggers that I should be aware of? This is happening in both development and production on Linux. I appreciate any insights! This issue appeared after updating to Javascript LTS. Any ideas how to fix this? Any ideas how to fix this?