Node: multipleResolves event emitted for Promise.race()

Created on 20 Nov 2018  路  3Comments  路  Source: nodejs/node

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.

  • Version: 10.13.0
  • Platform: all
  • Subsystem: Promise

Most helpful comment

This seems like a duplicate of #24321

All 3 comments

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

Was this page helpful?
1 / 5 - 1 ratings

Related issues

willnwhite picture willnwhite  路  3Comments

loretoparisi picture loretoparisi  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments

sandeepks1 picture sandeepks1  路  3Comments

filipesilvaa picture filipesilvaa  路  3Comments