mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-03-23 02:19:22 +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 {
|
for {
|
||||||
if err := s.Open(ctx); err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
// Non-fatal error, retry.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.Wait(ctx); err != nil {
|
if err := s.Wait(ctx); err != nil {
|
||||||
if opts.ErrorIsFatalClose(err) {
|
if opts.ErrorIsFatalClose(err) {
|
||||||
|
// Gateway returned a fatal error, so we can't recover.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if ctx.Err() == nil {
|
if ctx.Err() != nil {
|
||||||
return err
|
// 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