firebase-functions: Intent to implement: retry option for event triggered functions

Overview

Based on a discussion in https://github.com/firebase/firebase-functions/pull/370 I’d like to propose an improved version of the feature that should cover the concerns raised in the original implementation. I’m willing to work on adding this feature.

Design proposal

Definitions

Let new function with retries be a Cloud Function which has the option for reties set and it’s previous deployment did not have reties enabled.

Changes in firebase-functions

Extend an interface of RuntimeOptions of a FunctionBuilder in the following way:

interface FailurePolicy {
  retry: {};
}

interface RuntimeOptions {
  failurePolicy: FailurePolicy;
  memory?: '128MB' | '256MB' | '512MB' | '1GB' | '2GB';
  timeoutSeconds?: number;
}

I’d most likely dive a little deeper to make sure that this option is not present for https triggers.

Some might wonder why a retry option is an object. I followed the interface of the Cloud Functions API which specifies it this way, most probably to support customization of this policy in the future in a non-breaking way. That’s why I decide to follow this approach here.

Changes in firebase-tools

Add a confirmation step to the deployment process for new function with retries with the following behavior:

  • Interactive shells: display a confirmation prompt with the following text: “The following functions will be retried in case of a failure: fnA, fnB, fnC [a list of all functions with retries, not only new function with retries]. Please make sure all of these functions are idempotent, see https://cloud.google.com/blog/products/serverless/cloud-functions-pro-tips-building-idempotent-functions to learn more. Retried execution is charged as any other execution. Would you like to proceed?”
  • In non interactive shells: display an error message (printed to standard error stream) with the following text: “The following functions have a retry policy: fnA, fnB, fnC. Please make sure all of these functions are idempotent, see https://cloud.google.com/blog/products/serverless/cloud-functions-pro-tips-building-idempotent-functions to learn more. Retried execution is charged as any other execution. Supply a --force option to suppress this error.” and exit the process with code 1.
  • In non interactive shells with --force option: proceed with the deployment.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 17 (15 by maintainers)

Most upvoted comments

Hey @merlinnot, lI’ve submitted the proposal to the API review council - its scheduled to be reviewed on 4/8/2019. I’ll post here again with the results, but I think it looks good .