Skip to content

fix: queueAsPromised.drained() resolves while queue is idle#64

Merged
mcollina merged 1 commit into
mcollina:masterfrom
typedarray:master
Jan 1, 2023
Merged

fix: queueAsPromised.drained() resolves while queue is idle#64
mcollina merged 1 commit into
mcollina:masterfrom
typedarray:master

Conversation

@typedarray

@typedarray typedarray commented Dec 30, 2022

Copy link
Copy Markdown
Contributor

This PR fixes #63 by returning early from queueAsPromised.drained when the queue is idle.

NOTE: This implementation does NOT call queue.drain if the queue is idle, which IMO makes sense. The docs state that queue.drain is a "Function that will be called when the last item from the queue has been processed by a worker." When the queue is idle and the user calls await queue.drained(), it's reasonable to assume that the user has already added and processed items from the queue, so queue.drain should have already been called when the last item was processed.

@typedarray typedarray marked this pull request as ready for review December 30, 2022 17:04

@mcollina mcollina left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit e291e17 into mcollina:master Jan 1, 2023
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.

promise queue drained() method never returns if the queue is already completed

2 participants