question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Promises Do Not Queue

See original GitHub issue

On L109, inside thePromise the .add() method returns, you call ._dequeue(), assumedly to begin processing the Promises. 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 Promises, 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:open
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
azproductioncommented, Jan 29, 2018

Your “Queue” does nothing.

@Crowes I don’t see your point. Are you trying to help or you came to insult this project and it’s contributors?

0reactions
InsertBeforeFlightcommented, Jan 29, 2018

Noticed your commit, thanks for testing that.

I’m trying to figure out how you’re avoiding ._dequeue() just instantly calling the promiseGenerator 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 is 0, then L160 will be relied on, unless it’s the first addition since onEmpty.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found