From 8edf847e732b57f792a26c499805d49011e03fad Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Tue, 3 Sep 2024 11:43:47 +0800 Subject: [PATCH] fix: render mutex release error --- src/view/rendererExplorer.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/view/rendererExplorer.ts b/src/view/rendererExplorer.ts index eb9345e..48aa612 100644 --- a/src/view/rendererExplorer.ts +++ b/src/view/rendererExplorer.ts @@ -17,7 +17,9 @@ export class RendererExplorer { ) {} async runQueue(fn: () => Promise): Promise { - let release: undefined | (() => void) = await this.renderMutex.acquire(); + let release = (await this.renderMutex.acquire()) as + | undefined + | (() => void); setTimeout(() => { if (release) { release(); @@ -30,8 +32,10 @@ export class RendererExplorer { try { return await fn(); } finally { - release(); - release = undefined; + if (release) { + release(); + release = undefined; + } } }