Fix slow locks in Chrome 106

This commit is contained in:
Eduard Kuzmenko 2022-10-09 00:49:58 +04:00
parent 5d0c7f81fe
commit 4e66b5bc9f
1 changed files with 4 additions and 2 deletions

View File

@ -192,8 +192,10 @@ export default class SuperMessagePort<
this.log.warn('created lock', id);
const promise = new Promise<void>((resolve) => this.heldLocks.set(port, {resolve, id}))
.then(() => this.heldLocks.delete(port));
navigator.locks.request(id, () => promise);
this.resendLockTask(port);
navigator.locks.request(id, () => {
this.resendLockTask(port);
return promise;
});
} else {
window.addEventListener('beforeunload', () => {
const task = this.createTask('close', undefined);