Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pavelgj opened this issue Feb 2, 2023 · 3 comments · Fixed by firebase/firebase-functions#1463 or #6391

Comments

@pavelgj
Copy link
Collaborator

pavelgj commented Feb 2, 2023

[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

@icopp
Copy link

icopp commented Mar 30, 2023

Any news on this issue?

@joehan joehan assigned taeold and unassigned colerogers Apr 4, 2023
@alexstroukov
Copy link

alexstroukov commented Jul 3, 2023

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" });
     }

@andy-lee-vat-calc
Copy link

upvote on this, any plans for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment