Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Multiple PromiseQueue instances share same queue. #7484

@jayther

Description

@jayther

I found an issue that multiple PromiseQueue instances share the same queue.

Took me a while to figure out what it was, but the issue is caused by defining _queue (and _curPromise) in the prototype. This is fine if only one PromiseQueue instance is being used at any given time, but _queue is initially defined only in the prototype, which gives all PromiseQueue instances the same queue (as per prototypal inheritance rules). This seems to be fixed when calling removeAll() for each instance, as it assigns an empty array to the instance's _queue, overriding the prototype's _queue definition.

I made a test that runs two queues and checks for both queues' _queue.length, and indeed they both increment when two is added to only one of the queues.

The fix is to define _queue in the constructor (along with _curPromise since it should be there anyway, even though it doesn't cause the issue).

I'll fix it and submit a PR. (Only really made this so we can keep track of it as an issue)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions