feat: add retry backoff for connection errors in retryOperation#4
Closed
feat: add retry backoff for connection errors in retryOperation#4
Conversation
…x into feat/87780-improve-logging
…onyxConnectionManager
…mprove-logging feat: Improve retryOperation and reportStorageQuota logging to include original error
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Errors like lost IDB connections, closing databases, and backing store failures now wait with exponential backoff (100ms * 2^attempt +/- 25% jitter) before retrying, giving the DB connection time to recover. Capacity errors (QuotaExceeded, disk full) keep immediate retry with eviction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Existing retry tests now use fake timers to handle backoff delays. New tests verify: exponential delay progression, connection error logging, and capacity errors remaining immediate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
OnyxUtils.retryOperationfor non-capacity storage errorsfastMerge,Onyx.mergeand combine merge functions inOnyxUtils#3, Omit null state and props to fix default props Expensify/react-native-onyx#5 from storage error investigation) account for 51.7% of all failures — immediate retry was ineffective, DB needs recovery time100ms → 200ms → 400ms → 800ms → 1600ms(±25% jitter), capacity errors keep immediate retry with evictionLinked Issues
Changes
lib/OnyxUtils.ts:CONNECTION_ERRORSconstants,wait()/getRetryDelay()helpers, backoff wired into non-capacity error branch ofretryOperationtests/unit/onyxUtilsTest.ts: Updated 2 existing tests for fake timers, added 3 new tests (exponential progression, connection error logging, capacity errors remain immediate)Test plan
npm run typecheckpassesnpm run lintpassesnpm test— 437/437 tests passshould apply exponential backoff delay for non-capacity errors)should log connection error with backoff delay info)should NOT apply backoff delay for capacity errors)🤖 Generated with Claude Code