diff options
author | Satya Rohith <me@satyarohith.com> | 2024-05-16 17:42:01 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-16 17:42:01 +0530 |
commit | 7893ab9f0bb406081723ce80829d3ad6303da162 (patch) | |
tree | 1ad05bb4fc1c25ffbcc3089259c44f676cb96a7e /ext/node/ops/http2.rs | |
parent | 00e6d41a9d86c3c1a2e8807461bab127e52f0a10 (diff) |
fix(ext/node): fix grpc error_handling example (#23755)
gRPC depends only on the END_STREAM flag to emit "trailers" event which
is responsible to propagate the errors correctly. This patch uses
Body::is_end_stream() to determine if a stream will end and set the
END_STREAM flag.
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/node/ops/http2.rs')
-rw-r--r-- | ext/node/ops/http2.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/node/ops/http2.rs b/ext/node/ops/http2.rs index b89990e0b..e0de8e474 100644 --- a/ext/node/ops/http2.rs +++ b/ext/node/ops/http2.rs @@ -423,7 +423,7 @@ pub struct Http2ClientResponse { pub async fn op_http2_client_get_response( state: Rc<RefCell<OpState>>, #[smi] stream_rid: ResourceId, -) -> Result<Http2ClientResponse, AnyError> { +) -> Result<(Http2ClientResponse, bool), AnyError> { let resource = state .borrow() .resource_table @@ -439,6 +439,7 @@ pub async fn op_http2_client_get_response( for (key, val) in parts.headers.iter() { res_headers.push((key.as_str().into(), val.as_bytes().into())); } + let end_stream = body.is_end_stream(); let (trailers_tx, trailers_rx) = tokio::sync::oneshot::channel(); let body_rid = @@ -450,11 +451,14 @@ pub async fn op_http2_client_get_response( trailers_rx: AsyncRefCell::new(Some(trailers_rx)), trailers_tx: AsyncRefCell::new(Some(trailers_tx)), }); - Ok(Http2ClientResponse { - headers: res_headers, - body_rid, - status_code: status.into(), - }) + Ok(( + Http2ClientResponse { + headers: res_headers, + body_rid, + status_code: status.into(), + }, + end_stream, + )) } enum DataOrTrailers { |