-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Should clearQueue() reject the pending promises? #25
Comments
There's no way to reject promises from the outside. We could maybe support cancelling them if they are of the type |
I take it you mean promises returned by the user-supplied function, but I'm not talking about those, I'm talking about the promises const generator = (fn, ...args) => new Promise(resolve => enqueue(fn, resolve, ...args));
^^^^^^^ We could change this to const generator = (fn, ...args) => new Promise((resolve, reject) => enqueue(fn, resolve, reject, ...args)); And refactor the queue entries to include |
BREAKING CHANGE: when clearQueue() is called, promises for queued function calls will be rejected. fix sindresorhus#25
BREAKING CHANGE: when clearQueue() is called, promises for queued function calls will be rejected. fix sindresorhus#25
Could you please add an example of how to |
@RichardBronosky maybe you have an old version installed? Looks like |
I think it would be better to support |
Reading the docs, I assumed this: try {
await Promise.all(things.map(async (thing) => limit(async () => {/*...*/}) ));
} catch (error) {
limit.clearQueue();
throw error;
} would prevent promises not yet queued from running. For example, if Is this correct? |
Right now it leaves them hanging indefinitely. It seems like undesirable behavior, though I guess it ultimately depends on the use case.
The text was updated successfully, but these errors were encountered: