Skip to content

fix: prevent duplicated UpdateFunction calls - #10759

Open
IzaakGough wants to merge 10 commits into
mainfrom
@invertase/fix-prevent-duplicated-update-function-calls
Open

IzaakGough wants to merge 10 commits into
mainfrom
@invertase/fix-prevent-duplicated-update-function-calls

Conversation

@IzaakGough

@IzaakGough IzaakGough commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10731.

  • Per-request retryOnPrematureClose flag. The API client resends a request once without keep-alive after a premature close. That error is raised while reading the response, after the server has already accepted the request, so resending a write can repeat it. The new flag (default true) lets a caller opt out.
  • Disabled for Cloud Functions writes. Create, update and delete calls for v1 and v2 set the flag to false. A resent UpdateFunction fails with 409 ABORTED, a resent create would hit the function the first call just made, and a resent delete would target one already being removed.

Unit tests in src/apiv2.spec.ts cover the retry with the flag off and on. The premature close was not reproduced against the live API.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request restricts retrying requests on premature close errors to specific HTTP methods by introducing a helper function, and adds corresponding unit tests. The review feedback correctly notes that the helper function is named isIdempotentMethod but includes POST, which is non-idempotent. It suggests renaming the function to shouldRetryMethod to maintain semantic correctness.

Comment thread src/apiv2.ts Outdated
Comment thread src/apiv2.ts Outdated
@IzaakGough
IzaakGough marked this pull request as ready for review July 3, 2026 14:33

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloud Functions v2: firebase deploy sends UpdateFunction twice in one deploy; duplicate fails with 409 ABORTED "unable to queue the operation"

2 participants