Skip to content

Provide ability to handle uncaught exceptions gracefully. #290

Open

Description

@majelbstoat

This is a feature request.

At the moment, if an error is thrown by a handler, the entire process crashes. I would love a facility to define an uncaughtErrorHandler so that the server can keep running. This would make servers a lot less brittle, as errors caused in one handler wouldn't cause issues for other requests. For example:

function uncaughtErrorHandler(request, err) {
  console.log(request, err) // or do something smarter.
  return {
    code: status.INTERNAL_ERROR,
    message: err.message
  }
}

const server = new grpc.Server({
  uncaughtErrorHandler
})

I would expect this to 1) log the error, 2) return the return value of uncaughtErrorHandler to the client.

Activity

  1. Crevil commented on Apr 22, 2018

    @Crevil
    Contributor
  2. nicolasnoble commented on Apr 22, 2018

    @nicolasnoble
    Contributor

    We've touched the subject of having generic wrapper mechanism, but we're not decided yet.

  3. Lihemen commented on Aug 23, 2023

    @Lihemen

    Any conclusion on this or workarounds in newer releases?

    The inability to have a global uncaughtErrorHandler makes the server so brittle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions