From 94dfe8136573700fd3c08079b4903f9c00a31973 Mon Sep 17 00:00:00 2001 From: dfahlander Date: Fri, 1 Dec 2023 14:59:51 +0100 Subject: [PATCH] Resolves #1837 There were two finally's that returned promises. They used to work before because of a faulty implementation of Promise.finally. When that faulty implementation was corrected in 4.0.1-beta.2, the faulty code started to lock tables endlessly in certain scenarios. --- addons/dexie-cloud/src/middleware-helpers/guardedTable.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/dexie-cloud/src/middleware-helpers/guardedTable.ts b/addons/dexie-cloud/src/middleware-helpers/guardedTable.ts index 40c3e87f1..71c604659 100644 --- a/addons/dexie-cloud/src/middleware-helpers/guardedTable.ts +++ b/addons/dexie-cloud/src/middleware-helpers/guardedTable.ts @@ -30,7 +30,7 @@ function readLock( const promise = (numWriters > 0 ? writers[numWriters - 1].then(() => fn(req), () => fn(req)) : fn(req) - ).finally(() => readers.splice(readers.indexOf(promise))); + ).finally(() => {readers.splice(readers.indexOf(promise))}); readers.push(promise); return promise; }; @@ -51,7 +51,7 @@ function writeLock( : readers.length > 0 ? allSettled(readers).then(() => fn(req)) : fn(req) - ).finally(() => writers.shift()); + ).finally(() => {writers.shift();}); writers.push(promise); return promise; };