insta catering
insta catering

Reputation: 160

Wouldn't a write/update triggered google cloud function that then writes to firestore cause an infinite loop?

Or am I missing something? Or has this already been addressed in their documentation

Upvotes: 1

Views: 51

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317362

Yes, a change to a document that triggered the function could cause an infinite loop. This is noted in the documentation, which you will find as you scroll through it. It says:

Note: Any time you write to the same document that triggered a function, you are at risk of creating an infinite loop. Use caution and ensure that you safely exit the function when no change is needed.

Essentially what it's saying is it's the programmer's responsibility to detect this situation and bail out of the function early, given that the work was already done in a previous invocation.

Upvotes: 2

Related Questions