Skip to content

Commit 1ba4412

Browse files
authored
Fix fallback to MemoryCryptoStore when LocalStorage unavailable (#4797)
Signed-off-by: Michael Telatynski <[email protected]>
1 parent e3a3a52 commit 1ba4412

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/crypto/store/indexeddb-crypto-store.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,12 @@ export class IndexedDBCryptoStore implements CryptoStore {
204204
);
205205

206206
try {
207+
if (!(globalThis.localStorage instanceof Storage)) {
208+
throw new Error("localStorage is not available");
209+
}
207210
return new LocalStorageCryptoStore(globalThis.localStorage);
208211
} catch (e) {
209-
logger.warn(`unable to open localStorage: falling back to in-memory store: ${e}`);
212+
logger.warn(`Unable to open localStorage: falling back to in-memory store: ${e}`);
210213
return new MemoryCryptoStore();
211214
}
212215
})

0 commit comments

Comments
 (0)