Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Close session properly if activation failed #657

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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