higherkindness / mu-haskell

Mu (μ) is a purely functional framework for building micro services.
http://higherkindness.io/mu-haskell/
Apache License 2.0
333 stars 19 forks source link

[grpc-server] Bidirectional streaming is not ended correctly #311

Closed akshaymankar closed 3 years ago

akshaymankar commented 3 years ago

Testing a simple service defined like this:

syntax = "proto3";
package mu.grpc.test;

message GreetingRequest {string name = 1; }

message GreetingResponse {string greeting = 1;}

service GreetingsService {
  rpc bidirectional (stream GreetingRequest) returns (stream GreetingResponse);
}

The bidirectional function is implemented like this:

bidirectional :: forall m. (MonadServer m, MonadIO m) => ConduitT () GreetingRequest m () -> ConduitT GreetingResponse Void m () -> m ()
bidirectional requests responses = do
  C.runConduit $ requests .| serveResponse .| responses
  liftIO $ putStrLn "Done!"
  where
    serveResponse :: ConduitT GreetingRequest GreetingResponse m ()
    serveResponse = do
      liftIO $ putStrLn "Server Waiting"
      mreq <- C.await
      case mreq of
        Nothing -> pure ()
        Just req -> do
          C.yield $ record1 $ "Greetings! " <> view #name req
          serveResponse

While testing with evans, I get this error at the end:

command call: failed to process bidi streaming RPC: rpc error: code = Internal desc = AsyncCancelled

Another thing to note is that "Done!" is never printed. So, it looks like the requests conduit never realises that the input is over.