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

PromiseQueue stopping when a promise is rejected. #7393

Closed
jayther opened this issue Apr 3, 2014 · 3 comments
Closed

PromiseQueue stopping when a promise is rejected. #7393

jayther opened this issue Apr 3, 2014 · 3 comments

Comments

@jayther
Copy link
Contributor

jayther commented Apr 3, 2014

I started using the utils/Async.PromiseQueue for an extension I'm creating (mostly for myself but will be available on GitHub when it's done). PromiseQueue is great, except when a promise in the queue is rejected, and then all of the potential promises in the queue are stuck and not run.

I took a look in the master branch code to look for the issue and indeed, in src/utils/Async in line 490, the PromiseQueue only attaches on the resolved state of the current promise ( .done() ). According to the JSDoc comment on top of .add(), the queue is supposed to go to the next promise regardless if the state of the current promise is resolved or rejected, meaning it should add itself to the current promise's .always().

For a quick fix in my extension, I extended the PromiseQueue to override the .add() function to use .always() instead of .done().

@njx
Copy link
Contributor

njx commented Apr 3, 2014

Good catch - I think I wrote this code and have only ever used it in situations where promises are never rejected. Would you be interested in submitting a PR to fix it (and add tests for these cases in Async-test)? If not, no problem - we can take a look at it later.

@jayther
Copy link
Contributor Author

jayther commented Apr 3, 2014

Sure, I'll submit a PR to fix it tonight.

@njx
Copy link
Contributor

njx commented Apr 4, 2014

Fixed by filer, closing.

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

No branches or pull requests

2 participants