Skip to content

Commit

Permalink
unsafe cancelledRace fix
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Sep 14, 2023
1 parent bf216d3 commit 5eead7c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5eead7c

Please sign in to comment.