Skip to content

uncaughtException origin is always unhandledRejection when package.json type is module #41328

@vladshcherbin

Description

@vladshcherbin

Version

v16.13.1

Platform

mac os 10.14.6, Darwin uladzislaus-mbp 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

  1. create a script file with contents:
process.on('uncaughtException', (_, origin) => {
  console.log('whoops, uncaughtException', origin)
})

unknownFunction()
  1. run node <name-of-the-file>
  2. you will see whoops, uncaughtException uncaughtException
  3. now, create a package.json file next to script file with contents:
{
  "type": "module"
}
  1. run node <name-of-the-file>
  2. now, the message will be whoops, uncaughtException unhandledRejection

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

In package.json file, type should be module to see the bug.

What is the expected behavior?

uncaughtException origin should be uncaughtException

What do you see instead?

uncaughtException origin is unhandledRejection

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions