Aborting ClientReadableStream results in error event being fired
- 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
Assessment
This issue has not been assessed yet.