From 29a07133d179c9d3b116507177dd172481bd7489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Fri, 15 Dec 2023 16:59:06 +0100 Subject: [PATCH] fix: deadlock --- src/lib/serial/device.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/serial/device.ts b/src/lib/serial/device.ts index 73591528..c73f8b02 100644 --- a/src/lib/serial/device.ts +++ b/src/lib/serial/device.ts @@ -179,12 +179,16 @@ export class CharaDevice { } result = await callback(send, read) } finally { + delete this.lock this.suspendDebounceId = setTimeout(() => { // cannot be locked here as all the code until clearTimeout is sync 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.lock = undefined resolve(result) } })