Skip to content

fix: recheck queue state before emitting deferred drain - #2086

Open
agammann wants to merge 1 commit into
caolan:masterfrom
agammann:fix-empty-queue-drain
Open

agammann wants to merge 1 commit into
caolan:masterfrom
agammann:fix-empty-queue-drain

Conversation

@agammann

Copy link
Copy Markdown

Pushing an empty array schedules a drain event. If actual work is added before that event runs, the scheduled callback still fires and await q.drain() resolves while tasks are pending.

Recheck q.idle() inside the deferred callback. Add regression tests for push, unshift, pushAsync, and unshiftAsync, each followed by real work before the scheduled drain runs. This reproduces the behavior reported in #1729 without mixing async workers and callbacks.

Validation on Node.js 24.19.0: all four new tests fail before the fix; all 694 Node tests pass afterward. ESLint passes for both changed files.

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