mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-04 10:47:57 +00:00
session: Fix Connect->Open not handling ctx
This commit is contained in:
parent
4db60bca9d
commit
789afaa88f
|
@ -231,19 +231,25 @@ func (s *Session) Connect(ctx context.Context) error {
|
|||
|
||||
for {
|
||||
if err := s.Open(ctx); err != nil {
|
||||
if opts.ErrorIsFatalClose(err) {
|
||||
if opts.ErrorIsFatalClose(err) || ctx.Err() != nil {
|
||||
// Fatal error or context is done, return.
|
||||
return err
|
||||
}
|
||||
// Non-fatal error, retry.
|
||||
continue
|
||||
}
|
||||
|
||||
if err := s.Wait(ctx); err != nil {
|
||||
if opts.ErrorIsFatalClose(err) {
|
||||
// Gateway returned a fatal error, so we can't recover.
|
||||
return err
|
||||
}
|
||||
if ctx.Err() == nil {
|
||||
return err
|
||||
if ctx.Err() != nil {
|
||||
// Context was done, so we can't recover. Exit with no error,
|
||||
// since we're just waiting.
|
||||
return nil
|
||||
}
|
||||
// Non-fatal error, retry.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue