Skip to content

Commit f7986a4

Browse files
committed
move recordEviction after remove
1 parent edc6ec8 commit f7986a4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

lib/OnyxUtils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,14 +887,19 @@ function retryOperation<TMethod extends RetriableOnyxOperation>(
887887
return reportStorageQuota(error);
888888
}
889889

890-
// Remove the least recently accessed key and retry. Tell the breaker we evicted so that, if the
891-
// retry comes back as another capacity failure, it counts as a no-progress cycle.
890+
// Remove the least recently accessed key and retry.
892891
Logger.logInfo(`Out of storage. Evicting least recently accessed key (${keyForRemoval}) and retrying. Error: ${error}`);
893892
reportStorageQuota(error);
894-
StorageCircuitBreaker.recordEviction();
895893

896894
// @ts-expect-error No overload matches this call.
897-
return remove(keyForRemoval).then(() => onyxMethod(defaultParams, nextRetryAttempt));
895+
return remove(keyForRemoval).then(() => {
896+
// Mark the eviction only once the deletion has actually completed, immediately before the
897+
// retry it pairs with. Recording earlier lets a concurrent write's capacity failure consume
898+
// the marker as a no-progress cycle while this deletion is still pending and may yet free
899+
// space — so the verdict belongs to the retry that follows the deletion, not the eviction call.
900+
StorageCircuitBreaker.recordEviction();
901+
return onyxMethod(defaultParams, nextRetryAttempt);
902+
});
898903
}
899904

900905
/**

0 commit comments

Comments
 (0)