Skip to content

Commit

Permalink
Revert "fix: cleanup call fiber on exit (#515)" (#539)
Browse files Browse the repository at this point in the history
This reverts commit 64b7ded.
  • Loading branch information
regiskuckaertz authored Aug 5, 2023
1 parent d3a21bd commit 44a827b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ object ListenerDriver {

def unaryInputListener[Req](
runtime: Runtime[Any],
scope: Scope.Closeable,
call: ZServerCall[_],
completed: Promise[StatusException, Unit],
request: Promise[Nothing, Req],
Expand All @@ -30,10 +29,13 @@ object ListenerDriver {
completed.await *>
call.sendHeaders(new Metadata) *>
request.await flatMap writeResponse
).onExit(ex =>
call.close(ListenerDriver.exitToStatus(ex), requestContext.responseMetadata.metadata).ignore *> scope.close(ex)
).ignore
.forkIn(scope)
).onExit(ex => call.close(ListenerDriver.exitToStatus(ex), requestContext.responseMetadata.metadata).ignore)
.ignore
// Why forkDaemon? we need the driver to keep runnning in the background after we return a listener
// back to grpc-java. If it was just fork, the call to unsafeRun would not return control, so grpc-java
// won't have a listener to call on. The driver awaits on the calls to the listener to pass to the user's
// service.
.forkDaemon
.map(fiber =>
new Listener[Req] {
override def onCancel(): Unit =
Expand Down Expand Up @@ -89,10 +91,8 @@ object ListenerDriver {
for {
completed <- Promise.make[StatusException, Unit]
request <- Promise.make[Nothing, Req]
scope <- Scope.make
listener <- unaryInputListener(
runtime,
scope,
zioCall,
completed,
request,
Expand Down

0 comments on commit 44a827b

Please sign in to comment.