grpc / grpc/grpc-node

Provide ability to handle uncaught exceptions gracefully.

Open
#290 3 comments 18 reactions 0 assignees View on GitHub
feature request package: @grpc/grpc-js package: grpc
Dominant language
TypeScript
Stars
4.8k
Forks
716
Avg merge
2d 3h
Merged PRs (30d)
10

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.