feat: add retry backoff for connection errors in retryOperation#775
Draft
leshniak wants to merge 4 commits intoExpensify:mainfrom
Draft
feat: add retry backoff for connection errors in retryOperation#775leshniak wants to merge 4 commits intoExpensify:mainfrom
leshniak wants to merge 4 commits intoExpensify:mainfrom
Conversation
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>
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.
Details
Add exponential backoff with jitter to
OnyxUtils.retryOperationfor non-capacity storage errors, framed as an instrumented experiment to determine the right mitigation strategy.Context: Connection-class errors — Chromium backing store failures (26.3%), WebKit connection drops (19.0%), and closing-database errors (6.4%) — account for 51.7% of all storage failures (investigation). Analysis of 7-day production logs via VictoriaLogs shows:
We have no data on whether introducing a delay (100ms-1600ms) would allow recovery. This PR adds backoff as a low-risk experiment to collect that data.
Changes:
lib/OnyxUtils.ts: AddedCONNECTION_ERRORSconstants (IDB + SQLite), backoff config (RETRY_BASE_DELAY_MS=100,RETRY_JITTER_FACTOR=0.25),wait()/getRetryDelay()helpers, wired backoff into non-capacity error branch ofretryOperation100ms → 200ms → 400ms → 800ms → 1600ms(±25% jitter, ~3.1s total max)Next steps based on production data:
Related Issues
Expensify/App#87782
Automated Tests
Updated 2 existing retry tests to use fake timers (backoff delays require timer advancement). Added 3 new tests:
should apply exponential backoff delay for non-capacity errors— verifies delay count and exponential growth patternshould log connection error with backoff delay info— verifies connection-specific log messageshould NOT apply backoff delay for capacity errors (immediate retry with eviction)— verifies capacity errors remain immediateAll 437 tests pass.
Manual Tests
npm run typecheckpassesnpm run lintpassesnpm testpasses (437/437)Author Checklist
### Related Issuessection aboveTestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A — library-level change, no UI
Android: mWeb Chrome
N/A — library-level change, no UI
iOS: Native
N/A — library-level change, no UI
iOS: mWeb Safari
N/A — library-level change, no UI
MacOS: Chrome / Safari
N/A — library-level change, no UI