Skip to content

Commit 2b6f496

Browse files
committed
remove StorageErrorClassValue type
1 parent f7986a4 commit 2b6f496

5 files changed

Lines changed: 9 additions & 13 deletions

File tree

lib/OnyxUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,13 +891,13 @@ function retryOperation<TMethod extends RetriableOnyxOperation>(
891891
Logger.logInfo(`Out of storage. Evicting least recently accessed key (${keyForRemoval}) and retrying. Error: ${error}`);
892892
reportStorageQuota(error);
893893

894-
// @ts-expect-error No overload matches this call.
895894
return remove(keyForRemoval).then(() => {
896895
// Mark the eviction only once the deletion has actually completed, immediately before the
897896
// retry it pairs with. Recording earlier lets a concurrent write's capacity failure consume
898897
// the marker as a no-progress cycle while this deletion is still pending and may yet free
899898
// space — so the verdict belongs to the retry that follows the deletion, not the eviction call.
900899
StorageCircuitBreaker.recordEviction();
900+
// @ts-expect-error No overload matches this call.
901901
return onyxMethod(defaultParams, nextRetryAttempt);
902902
});
903903
}

lib/storage/errors.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type {ValueOf} from 'type-fest';
2-
31
/**
42
* Shared vocabulary for storage write failures. The *classes* are engine-agnostic; the *matching*
53
* is not — each storage provider knows its own error dialect and owns its classifier (see each
@@ -26,8 +24,6 @@ const StorageErrorClass = {
2624
UNKNOWN: 'unknown',
2725
} as const;
2826

29-
type StorageErrorClassValue = ValueOf<typeof StorageErrorClass>;
30-
3127
/**
3228
* Normalizes any thrown value into a lowercased `{name, message}` pair for matching. Shared by every
3329
* provider's classifier so they all extract the error the same way.
@@ -40,4 +36,3 @@ function getErrorParts(error: unknown): {name: string; message: string} {
4036
}
4137

4238
export {StorageErrorClass, getErrorParts};
43-
export type {StorageErrorClassValue};

lib/storage/providers/IDBKeyValProvider/classifyError.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import type {ValueOf} from 'type-fest';
12
import {StorageErrorClass, getErrorParts} from '../../errors';
2-
import type {StorageErrorClassValue} from '../../errors';
33

44
/**
55
* Classifies an IndexedDB write failure into the shared storage taxonomy (lib/storage/errors.ts).
66
* Matching is done on the lowercased error name and message. This is the IndexedDB engine's own
77
* dialect — it is NOT shared with other engines.
88
*/
9-
function classifyIDBError(error: unknown): StorageErrorClassValue {
9+
function classifyIDBError(error: unknown): ValueOf<typeof StorageErrorClass> {
1010
const {name, message} = getErrorParts(error);
1111

1212
// Non-serializable data passed to IDBObjectStore.put — retrying is futile.

lib/storage/providers/classifySQLiteError.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type {ValueOf} from 'type-fest';
12
import {StorageErrorClass, getErrorParts} from '../errors';
2-
import type {StorageErrorClassValue} from '../errors';
33

44
/**
55
* Classifies a SQLite write failure into the shared storage taxonomy (lib/storage/errors.ts).
@@ -10,7 +10,7 @@ import type {StorageErrorClassValue} from '../errors';
1010
* SQLite surfaces fewer distinct write-failure shapes than IndexedDB. As telemetry from the UNKNOWN
1111
* bucket (see OnyxUtils.retryOperation) reveals recurring native errors, add matchers here.
1212
*/
13-
function classifySQLiteError(error: unknown): StorageErrorClassValue {
13+
function classifySQLiteError(error: unknown): ValueOf<typeof StorageErrorClass> {
1414
const {message} = getErrorParts(error);
1515

1616
// Device disk full.

lib/storage/providers/types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import type {ValueOf} from 'type-fest';
12
import type {OnyxKey, OnyxValue} from '../../types';
23
import type {FastMergeReplaceNullPatch} from '../../utils';
3-
import type {StorageErrorClassValue} from '../errors';
4+
import type {StorageErrorClass} from '../errors';
45

56
type StorageKeyValuePair = [key: OnyxKey, value: OnyxValue<OnyxKey>, replaceNullPatches?: FastMergeReplaceNullPatch[]];
67
type StorageKeyList = OnyxKey[];
@@ -89,11 +90,11 @@ type StorageProvider<TStore> = {
8990
getDatabaseSize: () => Promise<DatabaseSize>;
9091

9192
/**
92-
* Classifies a write error from THIS engine into the shared {@link StorageErrorClassValue} taxonomy.
93+
* Classifies a write error from THIS engine into the shared {@link StorageErrorClass} taxonomy.
9394
* Each provider owns its own matchers (IndexedDB DOMExceptions, SQLite messages, …) so the central
9495
* taxonomy stays engine-agnostic. Anything the provider doesn't recognize must return UNKNOWN.
9596
*/
96-
classifyError: (error: unknown) => StorageErrorClassValue;
97+
classifyError: (error: unknown) => ValueOf<typeof StorageErrorClass>;
9798

9899
/**
99100
* @param onStorageKeyChanged Storage synchronization mechanism keeping all opened tabs in sync

0 commit comments

Comments
 (0)