scalapb / zio-grpc

ScalaPB meets ZIO: write purely functional gRPC services and clients using ZIO
Apache License 2.0
259 stars 82 forks source link

Delay sending headers #574

Closed joroKr21 closed 1 week ago

joroKr21 commented 10 months ago

gRPC has a configurable retry mechanism, however it's disabled once the headers are sent. Because it's assuming that at this point the client state may have changed. https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid

gRPC servers should delay the Response-Headers until the first response message or until the application code chooses to send headers. If the application code closes the stream with an error before sending headers or any response messages, gRPC servers should send the error in Trailers-Only.

eugengarkusha commented 8 months ago

any updates?

thesamet commented 8 months ago

There is an existing pull request (#331) that appears abandoned. It would be great if someone can rebase, ensure it's properly tested and prepare it for merge.

joroKr21 commented 6 months ago

Hmm, master doesn't compile for me, so I don't think I will be able to do anything:

[error] -- Error: /Users/georgy/work/zio/zio-grpc/e2e/src/test/scala/scalapb/zio_grpc/CommonServiceSpec.scala:14:4
[error] 14 |    suite("unary request (common)")(
[error]    |    ^
[error]    |Toplevel definition EnableReflectiveInstantiation is defined in
[error]    |  /Users/georgy/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/portable-scala/portable-scala-reflect_sjs1_2.13/1.1.2/portable-scala-reflect_sjs1_2.13-1.1.2.jar(org/portablescala/reflect/annotation/package.class)
[error]    |and also in
[error]    |  /Users/georgy/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/portable-scala/portable-scala-reflect_2.13/1.1.2/portable-scala-reflect_2.13-1.1.2.jar(org/portablescala/reflect/annotation/EnableReflectiveInstantiation.class)
[error]    |One of these files should be removed from the classpath.
[info] compiling 2 Scala sources to /Users/georgy/work/zio/zio-grpc/e2e-web/target/js-2.13/classes ...

  exception while retyping this.$asInstanceOf[
  zio.test.ZIOSpecDefault & scalapb.zio_grpc.CommonTestServiceSpec &
    (CommonTestServiceSpec.this : zio.test.ZIOSpecDefault &
      scalapb.zio_grpc.CommonTestServiceSpec)

].suite[

    zio.test.Spec[
      scalapb.zio_grpc.testservice.ZioTestservice.TestServiceClient,
      io.grpc.StatusException]

]("unary request (common)") of class Apply # -1

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose

     while compiling: /Users/georgy/work/zio/zio-grpc/e2e/src/test/scala/scalapb/zio_grpc/CommonServiceSpec.scala
        during phase: erasure
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.10
    compiler version: version 3.3.1
thesamet commented 6 months ago

You might be trying to build the tests for e2eWebJS3 which is specifically broken. Try using e2eJVM2_13 or e2eJVM3/test to only run the JVM test suite, and would also lead to faster development cycles.

joroKr21 commented 6 months ago

Dunno, I just tried sbt compile - it will be easier for me to comment out this project while working 👍

thesamet commented 6 months ago

Sure, I'll fix master soon, in the meantime e2eJVM2_13/compile and e2eJVM2_13/test would do it.