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 bc22f4e commit 325cf76
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 @@ -162,7 +162,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, true)
err := c.write(r, body, true)
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 325cf76

Please sign in to comment.