Skip to content

Commit

Permalink
fix: client wait bug
Browse files Browse the repository at this point in the history
  • Loading branch information
woorui committed Aug 25, 2023
1 parent be4af69 commit f06a2b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"io"
"reflect"
"runtime"
"time"
Expand Down Expand Up @@ -266,6 +267,12 @@ func (c *Client) handleFrameError(err error, reconnection chan<- struct{}) {

c.errorfn(err)

// exit client program if stream has be closed.
if err == io.EOF {
c.ctxCancel()
return
}

// always attempting to reconnect if an error is encountered,
// the error is mostly network error.
select {
Expand Down
3 changes: 1 addition & 2 deletions core/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestMetadata(t *testing.T) {
func TestMetadataSlogAttr(t *testing.T) {
md := metadata.New(map[string]string{
"aaaa": "bbbb",
"cccc": "dddd",
})

buf := bytes.NewBuffer(nil)
Expand All @@ -50,5 +49,5 @@ func TestMetadataSlogAttr(t *testing.T) {

logger.Debug("test metadata", MetadataSlogAttr(md))

assert.Equal(t, "level=DEBUG msg=\"test metadata\" metadata.aaaa=bbbb metadata.cccc=dddd\n", buf.String())
assert.Equal(t, "level=DEBUG msg=\"test metadata\" metadata.aaaa=bbbb\n", buf.String())
}

0 comments on commit f06a2b3

Please sign in to comment.