diff --git a/lib/OnyxUtils.ts b/lib/OnyxUtils.ts index c777d30ac..dd36b3d06 100644 --- a/lib/OnyxUtils.ts +++ b/lib/OnyxUtils.ts @@ -1138,6 +1138,32 @@ function evictStorageAndRetry { + if (!cache.isEvictableKey(key)) { + return; + } + + evictableCount++; + evictableKeys.push(key); + if (evictionBlocklist[key]) { + blockedCount++; + } + }); + + Logger.logHmmm( + `Out of storage eviction failure debug:\n` + + `Total keys in storage: ${allKeys.length}\n` + + `Evictable keys found: ${evictableCount}\n` + + `Evictable keys blocked: ${blockedCount}\n` + + `Keys in eviction blocklist: ${Object.keys(evictionBlocklist).length}`, + ); + // If we have no acceptable keys to remove then we are possibly trying to save mission critical data. If this is the case, // then we should stop retrying as there is not much the user can do to fix this. Instead of getting them stuck in an infinite loop we // will allow this write to be skipped. diff --git a/lib/storage/index.ts b/lib/storage/index.ts index 97ec7ceed..6e0e07ee5 100644 --- a/lib/storage/index.ts +++ b/lib/storage/index.ts @@ -36,7 +36,19 @@ function tryOrDegradePerformance(fn: () => Promise | T, waitForInitializat promise.then(() => { try { - resolve(fn()); + const result = fn(); + + // Handle promise rejections for async operations + if (result instanceof Promise) { + result + .then((value) => resolve(value)) + .catch((promiseError) => { + // Pass through all async errors to higher-level error handling + reject(promiseError); + }); + } else { + resolve(result); + } } catch (error) { // Test for known critical errors that the storage provider throws, e.g. when storage is full if (error instanceof Error) {