feat(firestore): add retry support for WriteBatch commit#188
Open
developerjamiu wants to merge 2 commits intoinvertase:mainfrom
Open
feat(firestore): add retry support for WriteBatch commit#188developerjamiu wants to merge 2 commits intoinvertase:mainfrom
developerjamiu wants to merge 2 commits intoinvertase:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Fixes #63
Problem
Standalone write operations (
set,update,create,delete) useWriteBatch._commit()to send a single HTTP request to Firestore. If the server returns a transient error such asUNAVAILABLE,RESOURCE_EXHAUSTED, orABORTED, the operation fails immediately with no retry — even though the same request sent moments later would succeed.The retry infrastructure (
ExponentialBackoff,commitRetryCodes) was already ported from the Node.js SDK but never wired into the commit path.Solution
Added a retry loop to
WriteBatch._commit()using the existingExponentialBackoffand_maybeBackoff()utilities, matching the pattern already used in_runTransaction().Retry codes follow the Node.js SDK (
write-batch.tsline 443):ABORTED+commitRetryCodes(RESOURCE_EXHAUSTED,UNAVAILABLE).Transaction commits are excluded from this retry loop — they pass a
transactionIdand are already retried at the transaction layer.Changes
write_batch.dart: retry loop in_commit()for standalone commitswrite_batch_test.dart: 5 tests covering retry and non-retry pathsChecklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]).CHANGELOG.mdof the relevant packages.Changelog files must be edited under the form:
I have updated the documentation to match those changes.