From c253910c5695fe78e92cc3c51d28411fadb91448 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 14 Oct 2024 02:43:05 -0700 Subject: [PATCH] Session storage operations are synchronous, so wrap them in Promises to at least try and not block other processes. --- src/lib/safe.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/safe.ts b/src/lib/safe.ts index 7d9ae7b..6a2d3c8 100644 --- a/src/lib/safe.ts +++ b/src/lib/safe.ts @@ -58,7 +58,14 @@ export class Safe { encrypted: buffer.toHex(encrypted), iv: iv.hex } - storage.setItem(name, JSON.stringify(record)) + await new Promise((resolve, reject) => { + try { + storage.setItem(name, JSON.stringify(record)) + resolve() + } catch (err) { + reject(err) + } + }) passkey = '' } catch (err) { throw new Error(ERR_MSG) @@ -79,7 +86,9 @@ export class Safe { return null } - const item = storage.getItem(name) + const item = await new Promise(resolve => { + resolve(storage.getItem(name)) + }) if (item == null) { return null } -- 2.34.1