David Garcia
David Garcia

Reputation: 43

Firebase Cloud Functions for Firestore trigger doens't work unless redeploy

I have this function to handle contact submissions. It get's triggered onCreate for a document in a collection in Firestore. The function is using the new v1+ syntax and it works every time I deploy the function to Firebase.

I'm getting a weird behavior where the function works fine for a couple of weeks and then it stops working. I can see new documents being created on the collection but the function doesn't gets triggered.

There are no logs or errors in the console for the function. The trigger for the function in the dashboard clearly states:

document.create
/someCollection/{documentId}

Once I redeploy the same function (no change is done to the code) the function start triggering as normal.

Have anyone seen this behavior?

Upvotes: 3

Views: 524

Answers (1)

Rafal Zawadzki
Rafal Zawadzki

Reputation: 901

Solution: redeploy your functions and the problem should not happen ever again.


According to the Firebase documentation:

Max inactivity time for background functions = 30 days

The maximum amount of time that a background function can be kept without any invocation. Functions that are not invoked even once during this time may enter a state in which new events will not trigger them anymore. If this happens, such functions have to be redeployed to start working again. Note: This inactive state is not reflected in the UI, CLI, or API in any way.

However, a Firebase team member commented in another SO thread:

This limitation was removed as of today. You will have to redeploy your Cloud Functions one final time, but after that they shouldn't be auto-removed after 30 days anymore.

Upvotes: 2

Related Questions