From 53433498c1bbfe7ad394a21b93d00a2fbeffd479 Mon Sep 17 00:00:00 2001 From: MarSeventh <1193267292@qq.com> Date: Tue, 29 Jul 2025 20:29:27 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AE=BF=E9=97=AE=E9=80=9F=E5=BA=A6=EF=BC=9B=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9F=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/utils/indexManager.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/functions/utils/indexManager.js b/functions/utils/indexManager.js index d626a7ad..52f21530 100644 --- a/functions/utils/indexManager.js +++ b/functions/utils/indexManager.js @@ -1185,19 +1185,17 @@ async function promiseLimit(tasks, concurrency = BATCH_SIZE) { const promise = Promise.resolve().then(() => task()).then(result => { results[i] = result; return result; + }).finally(() => { + const index = executing.indexOf(promise); + if (index >= 0) { + executing.splice(index, 1); + } }); executing.push(promise); if (executing.length >= concurrency) { await Promise.race(executing); - // 移除已完成的Promise - for (let j = executing.length - 1; j >= 0; j--) { - if (results[i] !== undefined || promise === executing[j]) { - executing.splice(j, 1); - break; - } - } } }