Skip to content

fix(queue): return empty arrays for empty batches - #2115

Open
sricharanreddycheruku wants to merge 1 commit into
caolan:masterfrom
sricharanreddycheruku:new/queue-empty-batch-results
Open

sricharanreddycheruku wants to merge 1 commit into
caolan:masterfrom
sricharanreddycheruku:new/queue-empty-batch-results

Conversation

@sricharanreddycheruku

Copy link
Copy Markdown

Promise.all(q.pushAsync(tasks)) throws when tasks is empty and the queue is idle, because the empty-batch path returns undefined. The same call returns an empty array while the queue has pending work.

Return an empty array from that early path in push, unshift, pushAsync, and unshiftAsync. This keeps the array result consistent with nonempty batches and preserves the existing deferred drain event.

The regression tests cover idle and paused queues, including cargo, cargoQueue, and priorityQueue. All 14 new cases fail before the fix. Local checks passed on Node 18.20.8, 20.20.0, and 21.7.3, with 717 tests on each. npm test also passed lint on Node 20.

The Firefox 157.0.1 browser suite passed all 705 tests on Node 20. The coverage command also passed.

Independent validation on Windows Node 22: 18 focused regression and drain checks passed. Full Windows Node 20 CI and upstream CI have not run locally. git diff --check passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant