From 1ba4412260e397b01f236f2f665eed7b7025733d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 11 Apr 2025 10:27:09 +0100 Subject: [PATCH] Fix fallback to MemoryCryptoStore when LocalStorage unavailable (#4797) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/crypto/store/indexeddb-crypto-store.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/crypto/store/indexeddb-crypto-store.ts b/src/crypto/store/indexeddb-crypto-store.ts index 824ad0050..25b13ea4e 100644 --- a/src/crypto/store/indexeddb-crypto-store.ts +++ b/src/crypto/store/indexeddb-crypto-store.ts @@ -204,9 +204,12 @@ export class IndexedDBCryptoStore implements CryptoStore { ); try { + if (!(globalThis.localStorage instanceof Storage)) { + throw new Error("localStorage is not available"); + } return new LocalStorageCryptoStore(globalThis.localStorage); } catch (e) { - logger.warn(`unable to open localStorage: falling back to in-memory store: ${e}`); + logger.warn(`Unable to open localStorage: falling back to in-memory store: ${e}`); return new MemoryCryptoStore(); } })