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

Fix client connection leak on non-failure, non-interruption cases #648

Closed ghostdogpr closed 1 month ago

ghostdogpr commented 1 month ago

When using client streaming, if the stream is ended because of .take, .runHead or even .interruptWhen, the exit value in anyExitHandler is Success, not a failure or an interruption. In that case the underlying connection is not cancelled and could stay there forever.

As a fix, I moved the check of isSuccess to the method used for non-streaming cases, and in streaming cases we will always call cancel.