镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

unhandledRejection fails to occur if .catch() is used on the last promise #30953

Description

@coreyfarrell
  • Version: 12.13.1 / 13.3.0
  • Platform: Linux lt2.cfware.com 5.3.11-200.fc30.x86_64 #1 SMP Tue Nov 12 19:25:25 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Take the following script:

'use strict';

Promise.reject('rejection 1');
Promise.reject('rejection 2').catch(() => {});

The expected result is an unhandledRejection for rejection 1. This script produces no warnings on node.js 12 or 13.

Activity

  1. added
    confirmed-bugIssues and PRs for confirmed bugs.
    promisesIssues and PRs related to ECMAScript promises.
    on Dec 13, 2019
  2. addaleax commented on Dec 13, 2019

    @addaleax
    Member

    Something like this might help?

    diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js
    index 35ebb39115f3..7cd40f96cc98 100644
    --- a/lib/internal/process/promises.js
    +++ b/lib/internal/process/promises.js
    @@ -125,7 +125,8 @@ function handledRejection(promise) {
           return;
         }
       }
    -  setHasRejectionToWarn(false);
    +  if (maybeUnhandledPromises.size === 0 && asyncHandledRejections.length === 0)
    +    setHasRejectionToWarn(false);
     }
     
     const unhandledRejectionErrName = 'UnhandledPromiseRejectionWarning';

    @nodejs/promises-debugging @joyeecheung (I think this might have come from bf56671)

  3. joyeecheung commented on Dec 13, 2019

    @joyeecheung
    Member

    @addaleax Yeah, that’s likely, as the PR only passed whatever test we had and this does not seem to be tested by us.

  4. added a commit that references this issue on Dec 17, 2019
  5. added a commit that references this issue on Jan 14, 2020
  6. added a commit that references this issue on Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.promisesIssues and PRs related to ECMAScript promises.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions