sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.46k stars 185 forks source link

event:active is not emitted after each item processed while setting concurrency greater than 1 #64

Open benliu723 opened 5 years ago

benliu723 commented 5 years ago

active event

const queue = new PQueue({ concurrency: 5 });
queue.addAll(myTaskQueue);
queue.on('active', () => {
            console.log(`${queue.size} requests remain to be scraped, pending workers: ${queue.pending}`);
});

console log

    5 requests remain to be scraped, pending workers: 4

    4 requests remain to be scraped, pending workers: 4

    3 requests remain to be scraped, pending workers: 4

    2 requests remain to be scraped, pending workers: 4

    1 requests remain to be scraped, pending workers: 4
sindresorhus commented 5 years ago

// @timgit

benliu723 commented 5 years ago

Precisely, it is not emitted on every item processed, my task queue size is 10, however, it only logs the last 5 items.

szmarczak commented 5 years ago

Could you attach full code to reproduce the bug?