Skip to content

v2 functions don't support retry even though cloud functions gen2 do #5484

Closed
firebase/firebase-functions
#1463

Description

@pavelgj

[REQUIRED] Environment info

firebase-tools: 11.21.0

Platform: macOS

[REQUIRED] Test case

exports.customeventhandler = onCustomEventPublished(
  {
    eventType: "firebase.extensions.storage-resize-images.v1.complete",
    retry: true,
  },
  (e) => {
    console.log(JSON.stringify(e));
  });

[REQUIRED] Steps to reproduce

firebase deploy --only functions

[REQUIRED] Expected behavior

Should deploy function with retry policy

[REQUIRED] Actual behavior

Shows a warning Cannot set a retry policy on Cloud Function and does not set the retry policy.

Warning is coming from here:

logger.warn("Cannot set a retry policy on Cloud Function", endpoint.id);

EventTrigger has retryPolicy field, so it should be set when retry option is specified.
https://cloud.google.com/functions/docs/reference/rest/v2/projects.locations.functions#eventtrigger

Activity

  1. self-assigned this
    on Feb 7, 2023
  2. icopp commented on Mar 30, 2023

    @icopp

    Any news on this issue?

  3. assigned and unassigned on Apr 4, 2023
  4. alexstroukov commented on Jul 3, 2023

    @alexstroukov

    any news on this? its concerning that you cant deploy event functions with retries since the ability to retry an event is kind of the whole point.

    for anyone stuck on this you can update this file (with patch-package) to set a retryPolicy instead of the warning in the console as a temporary measure

    patches/firebase-tools+12.4.2.patch

    diff --git a/node_modules/firebase-tools/lib/gcp/cloudfunctionsv2.js b/node_modules/firebase-tools/lib/gcp/cloudfunctionsv2.js
    index 38ed977..8da2118 100644
    --- a/node_modules/firebase-tools/lib/gcp/cloudfunctionsv2.js
    +++ b/node_modules/firebase-tools/lib/gcp/cloudfunctionsv2.js
    @@ -241,7 +241,8 @@ function functionFromEndpoint(endpoint, source) {
             proto.renameIfPresent(gcfFunction.eventTrigger, endpoint.eventTrigger, "triggerRegion", "region");
             proto.copyIfPresent(gcfFunction.eventTrigger, endpoint.eventTrigger, "channel");
             if (endpoint.eventTrigger.retry) {
    -            logger_1.logger.warn("Cannot set a retry policy on Cloud Function", endpoint.id);
    +            gcfFunction.eventTrigger.retryPolicy = 'RETRY_POLICY_RETRY'
    +            // logger_1.logger.warn("Cannot set a retry policy on Cloud Function", endpoint.id);
             }
             gcfFunction.serviceConfig.environmentVariables = Object.assign(Object.assign({}, gcfFunction.serviceConfig.environmentVariables), { FUNCTION_SIGNATURE_TYPE: "cloudevent" });
         }
    
  5. andy-lee-vat-calc commented on Aug 30, 2023

    @andy-lee-vat-calc

    upvote on this, any plans for it?

  6. self-assigned this
    on Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions