mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Fix daft bug - promises weren't racing
This commit is contained in:
parent
63d2b4ab9e
commit
6f6c9e0cd0
1 changed files with 5 additions and 3 deletions
|
@ -17,9 +17,11 @@ export async function acquire(lockname: string, timeout= 2000) {
|
|||
|
||||
DESIRED_LOCKS[lockname] = time
|
||||
|
||||
await Promise.all([
|
||||
browser.runtime.sendMessage({type: "lock", command: "acquire", args: [lockname, time, ID]}),
|
||||
messageAllTabs("lock", "acquire", [lockname, time, ID]),
|
||||
await Promise.race([
|
||||
Promise.all([
|
||||
browser.runtime.sendMessage({type: "lock", command: "acquire", args: [lockname, time, ID]}),
|
||||
messageAllTabs("lock", "acquire", [lockname, time, ID]),
|
||||
]),
|
||||
new Promise(resolve => setTimeout(resolve, timeout)), // Take lock anyway after timeout
|
||||
])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue