Server panics close response streams without an error (unlike unary responses)
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Bug Report
0.9.2 (sorry it's a little old, I'm waiting for prost-wkt)
├── tonic v0.9.2
└── tonic-build v0.9.2
### Platform
Darwin Js-MacBook-Pro.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:23 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6020 arm64
### Description
A server panic in a unary response gives an error, but in a response stream just closes the stream indistinguishably from a normal termination. I double checked with wireshark and both a normal termination and panic send a HEADERS packet with "End Stream: True".
Regular panic:
```
async fn paniccheck(&self, _request: Request) -> Result, Status> {
panic!("test");
}
Response headers received:
(empty)
Response trailers received:
(empty)
Sent 1 request and received 0 responses
ERROR:
Code: Canceled
Message: stream terminated by RST_STREAM with error code: CANCEL
```
Empty stream:
```
type StreamemptycheckStream =
Pin> + Send + Sync + 'static>>;
async fn streamemptycheck(
&self,
_request: Request,
) -> Result, Status> {
let (_tx, rx) = mpsc::channel(1);
tokio::spawn(async move {});
let result_stream = ReceiverStream::new(rx);
Ok(Response::new(Box::pin(result_stream)))
}
Response headers received:
content-type: application/grpc
date: Sat, 07 Oct 2023 03:45:14 GMT
Response trailers received:
(empty)
Sent 1 request and received 0 responses
```
Panic stream:
```
type StreampaniccheckStream =
Pin> + Send + Sync + 'static>>;
async fn streampaniccheck(
&self,
_request: Request,
) -> Result, Status> {
let (_, rx) = mpsc::channel(1);
tokio::spawn(async move {
panic!("test");
});
let result_stream = ReceiverStream::new(rx);
Ok(Response::new(Box::pin(result_stream)))
}
Response headers received:
content-type: application/grpc
date: Sat, 07 Oct 2023 03:47:51 GMT
Response trailers received:
(empty)
Sent 1 request and received 0 responses
```
Could we make the stream behavior more like unary responses? I'll try unwinding the panic and sending an error, but it would be nice if it were built in.
Contributor guide
Assessment
This issue has not been assessed yet.