Skip to content

Commit 16aef2e

Browse files
leshniakclaude
andcommitted
feat: add exponential backoff delay to non-capacity error retries
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>
1 parent 58d2a8c commit 16aef2e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/OnyxUtils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,15 @@ function retryOperation<TMethod extends RetriableOnyxOperation>(error: Error, on
838838
}
839839

840840
if (!isStorageCapacityError) {
841+
const delay = getRetryDelay(currentRetryAttempt);
842+
const isConnectionError = CONNECTION_ERRORS.some((connError) => errorName?.includes(connError) || errorMessage?.includes(connError));
843+
844+
if (isConnectionError) {
845+
Logger.logInfo(`Connection error detected, retrying with backoff (${delay}ms). Error: ${error}. onyxMethod: ${onyxMethod.name}. retryAttempt: ${nextRetryAttempt}/${MAX_STORAGE_OPERATION_RETRY_ATTEMPTS}`);
846+
}
847+
841848
// @ts-expect-error No overload matches this call.
842-
return onyxMethod(defaultParams, nextRetryAttempt);
849+
return wait(delay).then(() => onyxMethod(defaultParams, nextRetryAttempt));
843850
}
844851

845852
// Find the least recently accessed evictable key that we can remove

0 commit comments

Comments
 (0)