Skip to content

Commit

Permalink
Resolves #1837
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dfahlander committed Dec 1, 2023
1 parent c5ab3f1 commit 94dfe81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/dexie-cloud/src/middleware-helpers/guardedTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function readLock<TReq extends { trans: DBCoreTransaction }, TRes>(
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;
};
Expand All @@ -51,7 +51,7 @@ function writeLock<TReq extends { trans: DBCoreTransaction }, TRes>(
: readers.length > 0
? allSettled(readers).then(() => fn(req))
: fn(req)
).finally(() => writers.shift());
).finally(() => {writers.shift();});
writers.push(promise);
return promise;
};
Expand Down

0 comments on commit 94dfe81

Please sign in to comment.