Skip to content

Commit

Permalink
Close conn on WriteResponse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
schmichael committed Feb 7, 2025
1 parent 07c54c2 commit 86f17c1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion codec/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@ func (c *goRpcCodec) WriteRequest(r *rpc.Request, body interface{}) error {
}

func (c *goRpcCodec) WriteResponse(r *rpc.Response, body interface{}) error {
return c.write(r, body)
err := c.write(r, body)
if err != nil {
// If error occurred writing a response, close the underlying connection.
// See hashicorp/net-rpc-msgpackrpc#15
c.Close()
}
return err
}

func (c *goRpcCodec) ReadResponseHeader(r *rpc.Response) error {
Expand Down

0 comments on commit 86f17c1

Please sign in to comment.