huntlabs / grpc-dlang

Grpc for D programming language, hunt-http library based.
Apache License 2.0
44 stars 6 forks source link

the server does not handle empty request message properly #33

Open mw66 opened 2 years ago

mw66 commented 2 years ago

If we send a request, with empty message: e.g.

https://github.com/huntlabs/grpc-dlang/blob/master/examples/SimpleDemo/source/client.d#L15

comment out this line

  // request.name = "Hunt";

Then the server side will fail this test: https://github.com/huntlabs/grpc-dlang/blob/662427bf68d6fc374f62c8730b41f198651b98b9/source/grpc/GrpcStream.d#L141

and be trapped here forever:

https://github.com/huntlabs/grpc-dlang/blob/662427bf68d6fc374f62c8730b41f198651b98b9/source/grpc/GrpcStream.d#L148

and complains:

2022-10-17 02:24:04 | 8291 | warning | onData | The data is not ready yet. | /.dub/packages/grpc-0.5.0-beta.2/grpc/source/grpc/GrpcStream.d:148

and never pass the request to the handler.

On the client side, will see error like this:

2022-10-17 02:43:19 | 11773 | debug | remove | hunt.concurrency.ScheduledThreadPoolExecutor.ScheduledFutureTask!void.ScheduledFutureTask[Cancelled] | /.dub/packages/hunt-extra-1.2.3/hunt-
extra/source/hunt/concurrency/ScheduledThreadPoolExecutor.d:1129       

You can also try using Empty message to see this bug on the server side:

google/protobuf/empty.proto or

message Empty {}

I even tried:

message NumberMsg {
  int64 value = 1;  // return number
}

  // on the client side:
  NumberMsg req = new NumberMsg();
  // but do not assign anything to req.value, the server side show the same bug.

I think we should fix this bug to handle empty message (e.g. empty string) properly.

Thanks.