Merged
requested to merge github/fork/mixmaxhq/feature/pause-waits-until-active-jobs-finished into feature/multi-as-lua
Created by: xdc0
This PR makes Queue#pause wait until all jobs in active state are completed before resolving.
Previously, when pausing a queue, it would immediately resolve the pause promise, making it difficult to perform a clean disconnection.
Queue#pause will consume the private method Queue#whenCurrentJobsFinished, which checks jobs in active state, if there are pending jobs, then it sets up a listener on the completed event to recheck for jobs in active state. Once active jobs reaches 0, it resolves and in turns resolves the promise returned by Queue#pause