Skip to content

Commit

Permalink
Merge pull request #657 from Maddin-619/fix/close_session_after_activ…
Browse files Browse the repository at this point in the history
…ate_failed

Bugfix: Close session properly if activation failed
  • Loading branch information
magiconair authored Jun 5, 2023
2 parents 9697a6e + e7fe39b commit cc2711e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (c *Client) Connect(ctx context.Context) error {
}

if err := c.ActivateSessionWithContext(ctx, s); err != nil {
c.closeSession(ctx, s) // ignore error since we cannot handle it anyway
c.CloseWithContext(ctx)
stats.RecordError(err)

Expand Down Expand Up @@ -888,7 +889,7 @@ func (c *Client) ActivateSessionWithContext(ctx context.Context, s *Session) err
// We decided not to check the error of CloseSession() since we
// can't do much about it anyway and it creates a race in the
// re-connection logic.
c.CloseSession()
c.CloseSessionWithContext(ctx)

c.setSession(s)
return nil
Expand Down

0 comments on commit cc2711e

Please sign in to comment.