Skip to content

multipleResolves event should not be triggered when using Promise.all() or Promise.race() #24321

Closed
@ehmicky

Description

@ehmicky

Version: v11.1.0
Platform: Linux myhost 4.18.0-10-generic #11-Ubuntu SMP Thu Oct 11 15:13:55 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

When using Promise.all() or Promise.race(), several child promises might be legitimately rejected. This might be intended by the developer, so it should not trigger a multipleResolves process error. This is in contrast to calling reject() several times in new Promise() which definitely indicates a programming error.

'use strict'

process.on('multipleResolves', function() {
  console.log('This should not be called')
})

Promise.all([Promise.reject(), Promise.reject()])

Use case 1: a unit test is checking that an async function returns a rejected promise. The unit test fires the function several times in parallel for performance reason. The test expects each function call to reject a promise. I.e. multipleResolves should not be fired.

Use case 2: I created a library log-process-errors which logs every process errors (including multipleResolves). The goal is to make sure process errors are properly logged in production, so they can be fixed. However this does not work if Node.js is triggering them where there is no programming errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssues that need assistance from volunteers or PRs that need help to proceed.promisesIssues and PRs related to ECMAScript promises.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions