fix: deadlock

This commit is contained in:
2023-12-15 16:59:06 +01:00
parent c3bd8431e5
commit 29a07133d1

View File

@@ -179,12 +179,16 @@ export class CharaDevice {
} }
result = await callback(send, read) result = await callback(send, read)
} finally { } finally {
delete this.lock
this.suspendDebounceId = setTimeout(() => { this.suspendDebounceId = setTimeout(() => {
// cannot be locked here as all the code until clearTimeout is sync // cannot be locked here as all the code until clearTimeout is sync
console.assert(this.lock === undefined) console.assert(this.lock === undefined)
this.lock = this.suspend().then(() => true) this.lock = this.suspend().then(() => {
delete this.lock
delete this.suspendDebounceId
return true
})
}, this.suspendDebounce) as any }, this.suspendDebounce) as any
this.lock = undefined
resolve(result) resolve(result)
} }
}) })