dialohq / ocaml-grpc

gRPC library for OCaml
https://dialohq.github.io/ocaml-grpc
BSD 3-Clause "New" or "Revised" License
58 stars 9 forks source link

Detecting closed stream #61

Open crackcomm opened 2 weeks ago

crackcomm commented 2 weeks ago

Currently the server keeps writing even after the client closes the connection.

I'm not sure if it's even possible to detect it.

wokalski commented 2 weeks ago

Cześć Łukasz, yes it is possible to detect it. I will test if the current rewrite in grpc-eio-noseq already handles that case.

One adjacent aspect of this, however, is handling of GOAWAY frames. https://github.com/anmonteiro/ocaml-h2/issues/240 https://github.com/anmonteiro/ocaml-h2/issues/241

This will further improve the ergonomics and bring this library closer to feature parity with Google's libs (ironically the best implementation of this behavior can be found in a GitHub issue ~https://github.com/grpc/grpc-go/issues/6019~ this is not the issue, I cannot find it but tldr; streams are closed on the second go away, the first one is to begin graceful shutdown procedure)

crackcomm commented 5 days ago

Do you know how we can detect this? I tried calling Body.Writer.is_closed on a writer returned by respond_with_streaming, but it was never actually true until Body.Writer.close was called by returning from the handler.