go-micro: [BUG] Micro API fails on streaming endpoint unexpected nil error

Describe the bug

  1. What are you trying to do? Run micro api gateway and call a streaming endpoint
  2. What did you expect to happen? Success, actual response
  3. What happens instead?
{
    "code": 500,
    "detail": "grpc: client streaming protocol violation: get <nil>, want <EOF>",
    "id": "go.micro.client",
    "status": "Internal Server Error"
}

How to reproduce the bug: micro version 2.0.0 micro api --address :8085 --namespace some.ns --handler rpc http localhost:8085/my/streaming/endpoint

If possible, please include a minimal code snippet here.

       ctx, cancel := context.WithCancel(ctx)
	ch, errCh := data.GetSomeData(ctx, cancel, s.db, s.service)

	for {
		select {
		case <-ctx.Done():
			stream.Close()
			return nil
		case err := <-errCh:
			return err
		case msg := <-ch:
			if msg == nil {
				return nil
			}
			err := stream.Send(msg)
			if err != nil {
				cancel()
				for len(ch) > 0 {
					<-ch
				}
				return errors.InternalServerError(s.service.Name(), err.Error())
			}
		}
	}

Environment: Go Version: please paste go version output here

go version go1.13.1 darwin/amd64

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

firstly update to go-micro and micro to v2.5.0, and we can check it.