Skip to content

Commit

Permalink
prevent a promise leak if any of the running resolve first
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Sep 5, 2023
1 parent ae82a4e commit be8983e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ThroatQueueFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ function ThroatQueueFunction(n = 5){
const deferred = Q.defer()
cancellationState.deferredWrap(deferred)
running = [...running, deferred.promise]
await Q.safeRace(running)
try {
await Q.safeRace(running)
} finally {
deferred.resolve(null)
}
}
let ret = async function(cancellationState, what){
if(what === null){
Expand Down

0 comments on commit be8983e

Please sign in to comment.