Skip to content

Awaiting unresolvable promise should throw instead of Node terminating the process. #43162

Closed
@masbicudo

Description

@masbicudo

Version

v17.9.0

Platform

Microsoft Windows NT 10.0.22000.0 x64

Subsystem

No response

What steps will reproduce the bug?

const p = new Promise((resolve, reject) => { })
try {
    await p
}
catch {
    console.log("unresolvable promise detected")
}

How often does it reproduce? Is there a required condition?

Always. No required condition.

What is the expected behavior?

This will crash the execution. Instead, shouldn't this be an exception?
If this can be detected to allow NodeJS to end execution, otherwise it would await forever, why not make it an exception to allow Javascript programs detect this condition, on the await promise statement.

What do you see instead?

NodeJS just stops executing and exists without any possibility of control from the executing script.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions