Skip to content

Commit

Permalink
Sending a large error should mention that we're out of space
Browse files Browse the repository at this point in the history
The returned error now includes the underlying error from the typed
writer, resulting in:
> failed to create outbound error frame: no more room in buffer
  • Loading branch information
prashantv committed Sep 6, 2018
1 parent 828571d commit e4699e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func (c *Connection) SendSystemError(id uint32, span Span, err error) error {
LogField{"id", id},
ErrField(err),
).Warn("Couldn't create outbound frame.")
return fmt.Errorf("failed to create outbound error frame")
return fmt.Errorf("failed to create outbound error frame: %v", err)
}

// When sending errors, we hold the state rlock to ensure that sendCh is not closed
Expand Down
19 changes: 19 additions & 0 deletions connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/uber/tchannel-go/testutils"
"github.com/uber/tchannel-go/testutils/testreader"
"github.com/uber/tchannel-go/tos"
"github.com/uber/tchannel-go/typed"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -626,6 +627,24 @@ func TestWriteArg3AfterTimeout(t *testing.T) {
})
}

func TestLargeSendSystemError(t *testing.T) {
testutils.WithTestServer(t, nil, func(ts *testutils.TestServer) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts := testutils.NewOpts().AddLogFilter("Couldn't create outbound frame.", 1)
client := ts.NewClient(opts)
conn, err := client.Connect(ctx, ts.HostPort())
require.NoError(t, err, "Connect failed")

largeErr := errors.New(strings.Repeat("1234567890", 10000))
err = conn.SendSystemError(1, Span{}, largeErr)
require.Error(t, err, "Expect err")
assert.Contains(t, err.Error(), typed.ErrBufferFull.Error())
assert.Contains(t, err.Error(), "wat")
})
}

func TestWriteErrorAfterTimeout(t *testing.T) {
// TODO: Make this test block at different points (e.g. before, during read/write).
testutils.WithTestServer(t, nil, func(ts *testutils.TestServer) {
Expand Down

0 comments on commit e4699e4

Please sign in to comment.