Skip to content

Commit

Permalink
Swallow exception when scheduling trailers
Browse files Browse the repository at this point in the history
(for already closed stream)
anmonteiro/ocaml-h2#175
  • Loading branch information
quernd committed Jul 22, 2023
1 parent 893a9a1 commit 61a6c12
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/grpc-eio/connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@ let grpc_send_streaming request =
H2.Body.Writer.write_string body payload
in
let on_eof status =
H2.Reqd.schedule_trailers request
(H2.Headers.of_list
([
( "grpc-status",
string_of_int (Grpc.Status.int_of_code (Grpc.Status.code status))
);
]
@
match Grpc.Status.message status with
| None -> []
| Some message -> [ ("grpc-message", message) ]));
(try
H2.Reqd.schedule_trailers request
(H2.Headers.of_list
([
( "grpc-status",
string_of_int
(Grpc.Status.int_of_code (Grpc.Status.code status)) );
]
@
match Grpc.Status.message status with
| None -> []
| Some message -> [ ("grpc-message", message) ]))
with
| Failure "h2.Reqd.schedule_trailers: stream already closed"
(* https://github.com/anmonteiro/ocaml-h2/issues/175 *)
->
());
H2.Body.Writer.close body
in
(on_msg, on_eof)

0 comments on commit 61a6c12

Please sign in to comment.