For 'multipleResolves' to be useful in debugging scenarios, we should treat it as an error-like condition. However, Promise.race() implementation triggers it:
process.on('multipleResolves', function () {
console.log('multipleResolves', arguments)
// currently prints:
// multipleResolves [Arguments] { '0': 'resolve', '1': Promise { 'a' }, '2': 'b' }
})
Promise.race([Promise.resolve('a'), Promise.resolve('b')])
I would recommend we change Promise.race()聽 implementation in V8 to only call resolve once. Would it be something that could be landed in V8?
cc @benjamingr @BridgeAR @bmeurer @nodejs/v8 @nodejs/promises-debugging
Originally reported as https://github.com/mcollina/make-promises-safe/issues/12.
This seems like a duplicate of #24321
race/all only calling resolve/reject once would be visible to someone doing Promise.race.call(notPromise) (and break the spec)
Duplicate of #24321
Most helpful comment
This seems like a duplicate of #24321