Skip to content

implement process.exitWithException() #34051

Closed

Description

@jasnell

In the stalled PR #25715, @Fishrock123 was working to introduce a new API... from the original description:

Adds a public way to access node::FatalException from javascript, as process.exitWithException().

If an error stack is available on the value, this method of exiting does not add additional context, unlike regular re-throwing, yet also uses the regular error printing logic. This behavior is particularly desirable when doing 'fatal exits' from the unhandledRejection event.

While the PR had plenty of support to move forward, there was an edge case around the uncaughtException event handler that would need to be worked through in order for it to move forward.

The original PR stalled out and has been closed, but given the support the idea had, I wanted to make sure to open a Feature Request issue in case someone else wanted to pick up the work and move it forward.

Activity

  1. added
    feature requestIssues requesting new Node.js features.
    processIssues and PRs related to the process subsystem.
    on Jun 25, 2020
  2. bnoordhuis commented on Jun 26, 2020

    @bnoordhuis
    Member

    This behavior is particularly desirable when doing 'fatal exits' from the unhandledRejection event.

    Is that different from this?

    process.on('unhandledRejection', err => {
      console.error(err)
      process.exit(42)
    })

    I assume the difference is that the proposed API also prints the line that threw? You probably don't always want to quit so I'd say that's better handled through a new API, one that gives you that line.

  3. bnoordhuis commented on Jul 6, 2020

    @bnoordhuis
    Member

    @Fishrock123 @jasnell Can you comment on the above?

  4. jasnell commented on Jul 6, 2020

    @jasnell
    MemberAuthor

    I have no particular preference on this. I opened issue so that the request didn't get lost since the original work stalled out.

  5. jasnell commented on Jan 12, 2021

    @jasnell
    MemberAuthor

    Closing due to lack of progress

  6. Fishrock123 commented on Jan 12, 2021

    @Fishrock123
    Contributor

    The idea was essentially to expose the built-in error printing logic.

    I also no longer have any investment in this, so, as we were.

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

    feature requestIssues requesting new Node.js features.processIssues and PRs related to the process subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions