Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Idempotency in Google Cloud Function HTTPS triggers

Most firebase cloud function trigger function signatures include a context object which has an eventId property.

Looking at the documentation, this doesn't seem to be the case for HTTPS-triggers.

Is it safe to assume that calls to HTTP functions will only trigger once per request?

like image 287
Mickel Avatar asked Oct 31 '25 19:10

Mickel


2 Answers

Jack's answer is mostly correct, but I'll clarify here.

The documentation on execution semantics is here. To be clear:

HTTP functions are invoked at most once. This is because of the synchronous nature of HTTP calls, and it means that any error on handling function invocation will be returned without retrying. The caller of an HTTP function is expected to handle the errors and retry if needed.

There is no guarantee that an HTTP function is executed exactly once. Some executions may fail before they reach the function. This is different from all other (background) types of function that provider at least once execution:

Background functions are invoked at least once. This is because of asynchronous nature of handling events, in which there is no caller that waits for the response and could retry on error. An emitted event invokes the function with potential retries on failure (if requested on function deployment) and sporadic duplicate invocations for other reasons (even if retries on failure were not requested).

So, for background functions to be 100% correct, they should be idempotent.

If you want to retry failed HTTP functions, the client will have to perform the retry, and in that case, you may want that HTTP function to be idempotent as well. The client will have to provide the unique key on retry, in that case.

Note that it's not possible to mark an HTTP function for internal retries. That's only possible for background functions.

like image 186
Doug Stevenson Avatar answered Nov 03 '25 12:11

Doug Stevenson


HTTPS functions will only trigger once compared to background functions that have a at least once delivery guarantee.

(I cant find the docs where I read it. If I find it i will update the question)

like image 29
Jack Woodward Avatar answered Nov 03 '25 12:11

Jack Woodward