grpc / grpc/grpc-web

Aborting ClientReadableStream results in error event being fired

Open
#544 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
802
Avg merge
1d 7h
Merged PRs (30d)
5

Description

I believe this is handled here: https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js#L199

Calling `.abort()` results in `"error"` event being triggered, this is problematic in situations such as this:
```
// User interacts with UI, we trigger grpc request:
const stream = myService.method();

// We setup error handler in request, displaying error in UI to user
stream.on("error", err => {
displayErrorMessageToUser();
});

// User clicks "cancel" button to abort grpc service request
stream.cancel();
```
In this example, the user will be shown an "error" message after they have aborted a request.

This issue is compounded by the fact that `err.code` passed to the `"error"` callback uses `grpcWeb.StatusCode.UNAVAILABLE` instead of `grpcWeb.StatusCode.ABORTED` meaning we can't even reliably check in the error callback the nature of the error being fired.

In my opinion a client-initiated cancellation of a gRPC-web request should _not_ trigger an error.

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.