From 525ffcd3d73abc3e894803cf7df6b653f0e1957c Mon Sep 17 00:00:00 2001 From: CI010 Date: Fri, 29 Mar 2024 11:08:42 +0800 Subject: [PATCH] fix: Avoid some dead locks during installing instance --- xmcl-runtime-api/src/util/mutex.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xmcl-runtime-api/src/util/mutex.ts b/xmcl-runtime-api/src/util/mutex.ts index 3a7a04b97..283c085dd 100644 --- a/xmcl-runtime-api/src/util/mutex.ts +++ b/xmcl-runtime-api/src/util/mutex.ts @@ -34,10 +34,14 @@ export class ReadWriteLock { private async processIfIdle() { if (this.status === LockStatus.Idle) { while (this.queue.length > 0) { - const [operation, release] = this.queue.shift()! - this.release = release - this.status = release ? LockStatus.Reading : LockStatus.Writing - await operation() + try { + const [operation, release] = this.queue.shift()! + this.release = release + this.status = release ? LockStatus.Reading : LockStatus.Writing + await operation() + } catch { + // no-op + } } this.status = LockStatus.Idle }