Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushing an empty task onto the queue in q.drain results in an infinite loop. #1791

Closed
hargasinski opened this issue Jan 24, 2022 · 2 comments
Assignees

Comments

@hargasinski
Copy link
Collaborator

What version of async are you using? v3.2.3

Which environment did the issue occur in (Node/browser/Babel/Typescript version) node & browser

What did you do? Please include a minimal reproducible case illustrating issue.

const q = async.queue(() => {})
q.drain(() => { q.push([]) })
q.push([])

What did you expect to happen?
The queue doesn't schedule another drain call if one is running.

What was the actual result?
The queue goes into an infinite loop.

I'm not sure this is necessarily a bug as queue is working as specified - if an empty task is pushed and it's idle, it drains. I only noticed it because in the priorityQueue tests, we have a test for this case, see tests/priorityQueue#L52. With the changes in #1790, the priorityQueuebehaves the same way as queue and goes into an infinite loop. We could add a check that if a drain call is running, not to schedule another one similar to what we do with q._process. Thoughts?

@aearly
Copy link
Collaborator

aearly commented Jan 28, 2022

Yes, lets add the extra check to avoid an infinite loop. There are cases where you could accidentally get into this state and crash your app.

@hargasinski hargasinski self-assigned this Feb 2, 2022
@hargasinski
Copy link
Collaborator Author

Sounds good, I'll create a PR for it this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants