From a566dd390b00e1647530a9989e4dd705ca26bb1e Mon Sep 17 00:00:00 2001 From: linyuchen Date: Mon, 6 May 2024 19:44:25 +0800 Subject: [PATCH] fix: rkey cached --- src/common/utils/AsyncQueue.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/common/utils/AsyncQueue.ts b/src/common/utils/AsyncQueue.ts index f6f19c8c..bbce654c 100644 --- a/src/common/utils/AsyncQueue.ts +++ b/src/common/utils/AsyncQueue.ts @@ -1,6 +1,6 @@ import { sleep } from '@/common/utils/helper'; -type AsyncQueueTask = (() => void) | Promise ; +type AsyncQueueTask = (() => void) | (()=>Promise); export class AsyncQueue { @@ -8,20 +8,22 @@ export class AsyncQueue { public addTask(task: AsyncQueueTask) { this.tasks.push(task); + // console.log('addTask', this.tasks.length); if (this.tasks.length === 1) { this.runQueue().then().catch(()=>{}); } } private async runQueue() { + // console.log('runQueue', this.tasks.length); while (this.tasks.length > 0) { const task = this.tasks[0]; + // console.log('typeof task', typeof task); try { - if (task instanceof Promise) { - await task; - } - else{ - task(); + const taskRet = task(); + // console.log('type of taskRet', typeof taskRet, taskRet); + if (taskRet instanceof Promise) { + await taskRet; } } catch (e) { console.error(e);