Skip to content Skip to sidebar Skip to footer

Bluebird's Promise.settle Doesn't Resolve With The Correct Values

I have the following code: return Promise.settle(matches, imgur.uploadUrl) .map(function (inspection) { if (inspection.isFulfilled()) { return inspection.va

Solution 1:

When I look at the Bluebird source for Promise.settle(), I only see that it processes the first argument (expecting an array of promises). I've always just used it as a substitute for Promise.all() when you want all promises to complete, even if some have errors.

I wonder if the Bluebird documentation for .settle() is just wrong about it taking a function as the second argument that will process the first array? The code is a little hard to follow, but I don't see how Promise.settle() ever uses the 2nd argument (unless this isn't the right code I'm looking at for some reason).

As you pointed out, an alternative is:

Promise.settle(matches.map(imgur.uploadUrl)).then(...)

which just passes an array of promises to .settle().


FYI, I verified by creating a simple test case and stepping into Promise.settle() in the debugger that it never uses the second argument passed to it. This appears to be a case of the documentation not matching the implementation. I expect someone planned to implement what is documented, but never completed that implementation.

Solution 2:

This was indeed a bug in the docs. It was fixed (props to OP for the pull request).

The docs now show the correct usage of .settle.

Post a Comment for "Bluebird's Promise.settle Doesn't Resolve With The Correct Values"