Skip to content

Commit

Permalink
fix remaining issues found by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhump committed Dec 5, 2023
1 parent 39a162c commit d42edba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func receiveUnaryResponse[T any](conn StreamingClientConn, initializer maybeInit
if err := conn.Receive(&msg2); err == nil {
return nil, NewError(CodeUnknown, errors.New("unary stream has multiple messages"))
} else if err != nil && !errors.Is(err, io.EOF) {
return nil, NewError(CodeUnknown, err)
return nil, err
}
return &Response[T]{
Msg: &msg,
Expand Down
14 changes: 8 additions & 6 deletions duplex_http_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,15 @@ func (d *duplexHTTPCall) CloseRead() error {
if d.response == nil {
return nil
}
if _, err := discard(d.response.Body); err != nil &&
!errors.Is(err, context.Canceled) &&
!errors.Is(err, context.DeadlineExceeded) {
_ = d.response.Body.Close()
return wrapIfRSTError(err)
_, err := discard(d.response.Body)
closeErr := d.response.Body.Close()
if err == nil ||
errors.Is(err, context.Canceled) ||
errors.Is(err, context.DeadlineExceeded) {
err = closeErr
}
return wrapIfRSTError(d.response.Body.Close())
err = wrapIfContextError(err)
return wrapIfRSTError(err)
}

// ResponseStatusCode is the response's HTTP status code.
Expand Down
4 changes: 4 additions & 0 deletions envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ func (r *envelopeReader) Unmarshal(message any) *Error {
if env.Flags != 0 && env.Flags != flagEnvelopeCompressed {
// Drain the rest of the stream to ensure there is no extra data.
if n, err := discard(r.reader); err != nil {

Check failure on line 208 in envelope.go

View workflow job for this annotation

GitHub Actions / ci (1.21.x)

variable name 'n' is too short for the scope of its usage (varnamelen)
err = wrapIfContextError(err)
if connErr, ok := asError(err); ok {
return connErr
}
return errorf(CodeInternal, "corrupt response: I/O error after end-stream message: %w", err)
} else if n > 0 {
return errorf(CodeInternal, "corrupt response: %d extra bytes after end of stream", n)
Expand Down

0 comments on commit d42edba

Please sign in to comment.