From 5eead7c62210b32815e389f73667194ce932155c Mon Sep 17 00:00:00 2001 From: Mathew Date: Thu, 14 Sep 2023 16:38:47 +1000 Subject: [PATCH] unsafe cancelledRace fix --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index fbcf5ec..4c8e9b6 100644 --- a/index.js +++ b/index.js @@ -180,7 +180,12 @@ Q.safeRace = async function(contenders) { Q.cancelledRace = async function (promises, safeRace = true) { let ret try { - ret = await (safeRace ? Q.safeRace : Promise.race)(promises) + if(safeRace){ + ret = Q.safeRace(promises) + } else { + ret = Promise.race(promises) + } + ret = await ret } finally { for (const p of promises) { if (p.cancel) p.cancel()