Skip to content

Promise.reject() crashes repl when using --unhandled-rejections=strict #35232

@dfabulich

Description

@dfabulich
  • Version: 14.11.0
  • Platform: macOS Catalina 10.15.6

I have also reproduced this in Node 12.18.4.

What steps will reproduce the bug?

Launch the repl with this command:

node --unhandled-rejections=strict

(--unhandled-rejections=throw has the same issue.)

On the repl command line, type Promise.reject().

What is the expected behavior?

When an uncaught error is thrown in the repl, the repl should print "Uncaught error" without terminating the process. For example:

> throw new Error()
Uncaught Error
> void setTimeout(_=>{throw new Error()}, 0)
undefined
> Uncaught Error

What do you see instead?

The process crashes.

> Promise.reject()
Promise { <rejected> undefined }
> internal/process/promises.js:213
        triggerUncaughtException(err, true /* fromPromise */);
        ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Additional information

This bug will become more important in Node 15 when --unhandled-rejections=throw becomes the default, per PR #33021. At that point, the bug will repro when launching node using the default settings with no flags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions