UnhandledPromiseRejection(s) from .some, .any, etc
eurostar-fennec-cooper opened this issue · 1 comments
- What version of bluebird is the issue happening on?
3.7.2 - What platform and version? (For example Node.js 0.12 or Google Chrome 32)
NodeJS 12.16.2 - Did this issue happen with earlier version of bluebird?
Yes
When using Bluebird methods that resolve as soon as one of many promises has resolved, if any of the others are rejected, this results in an UnhandledPromiseRejection.
It doesn't seem like there's a clean way to handle the: resolution/rejection of the first promise to be resolved/rejected and additionally and separately handle: any rejections of the other promises. If anybody has any suggestions, I'm all ears.
Example:
const bluebird = require('bluebird');
const goodFn = () => Promise.resolve('success');
const badFn = () =>bluebird.delay(200).then(() => { throw new Error('failure'); });
bluebird.any(goodFn(), badFn()).then(console.log).catch(console.error);
In this example, I am unable to handle the rejection of badFn. I could handle rejections globally, but I don't really want to resort to that; it would be nice if Bluebird was able to be provided a handler that is used for all promises of some/any/etc that are rejected after the first promise has resolved.
Bluebird.any
takes an array (or other iterable) as its argument, not multiple arguments.