Utilize locks to prevent certain edge case issues

This commit is contained in:
Zaid Humaimidi committed 2023-12-06 11:10:23 -08:00
1 parent f4596db9f7
commit 342210faf1
7 files changed
+323 -269

No files matched your search

+2 -2
View File
@@ -44,7 +44,7 @@ export async function releaseLock(
if (res.deletedCount !== 1) throw new Error("Lock expired");
}
export async function lockExists(lockName: string): Promise<boolean> {
export async function getToken(lockName: string): Promise<string> {
const res = await collections.locks.findOne({ _id: lockName });
return res != null;
return res?.value;
}