Promises Do Not Queue
See original GitHub issueOn L109, inside thePromise
the .add()
method returns, you call ._dequeue()
, assumedly to begin processing the Promise
s. What this causes is for every added Promise
to dequeue as soon as it is actually queued.
This should only ever happen if there aren’t any currently pending. If there are pending Promise
s, the recursive method will reach them eventually anyway. It would fail this test having them resolve in time order, not in the order they were queued.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
How to manage Promises into dynamic queue with vanilla ...
Now, we are going to implement adding promises to queue array. Important: what we add to queue is not the promise itself, but...
Read more >Using a task queue vs. just not waiting for Promise to resolve
When you don't wait for the Promise to resolve, the most important thing to remember is that Node is still processing that Promise...
Read more >Queueing Javascript Promises
We will use Promises to call the next item from our queue. A Promise is essentially a placeholder that says, "I don't have...
Read more >Using Promises as a queue - DEV Community
One of them is to use Promises as a queue. But what if you have an arbitrary number of operations to run? And...
Read more >sindresorhus/p-queue: Promise queue with concurrency control
Returns a promise that settles when the queue size is less than the given limit: queue.size < limit . If you want to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Crowes I don’t see your point. Are you trying to help or you came to insult this project and it’s contributors?
Noticed your commit, thanks for testing that.
I’m trying to figure out how you’re avoiding
._dequeue()
just instantly calling thepromiseGenerator
as soon as it’s added, considering L109; realistically that only needs to happen to get recursion (that is caused by the same call on L160 f/e) going. With it being called all the time, L160 becomes redundant, I’d assume, because they’ll all have been shifted by that point.If you call L109 only when
.pendingPromises
is0
, then L160 will be relied on, unless it’s the first addition sinceonEmpty
.