question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intent to implement: retry option for event triggered functions

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
joehancommented, Apr 1, 2019

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 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Functions retry policy for Event Hubs and timer triggers
Azure Functions now supports setting a retry policy for Azure Event Hubs and timer triggers.
Read more >
How to retry events in Amazon EventBridge! - Medium
EventBridge allows to archive and replay events. ... The replay trigger function uses it to set the EventStartTime and the EventEndTime of ...
Read more >
Developing for retries and failures - AWS Lambda
For failures within the custom code of a Lambda function, the service offers a number of features to help preserve and retry the...
Read more >
javascript - Promise Retry Design Patterns - Stack Overflow
reject(new Error("checkStatus() timeout")); } return work.requestStatus().then(function(result) { switch(result.status) { ...
Read more >
Retrying event-driven functions - Google Cloud
If the failure is due to a bug or any other sort of permanent error, your function can get stuck in a retry...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found