Skip to content

Commit

Permalink
fix(fc2): pass error canceled, which triger the end of errgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness4 committed Nov 1, 2023
1 parent 4f34068 commit 8ee0fd8
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions fc2/fc2.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,15 @@ func (f *FC2) HandleWS(

g, ctx := errgroup.WithContext(ctx)
g.Go(func() error {
if err := ws.HeartbeatLoop(ctx, conn, msgChan); err != nil {
if err == io.EOF {
f.log.Info().Msg("healthcheck finished")
return err
} else if errors.Is(err, context.Canceled) {
f.log.Info().Msg("healthcheck canceled")
} else {
f.log.Error().Err(err).Msg("healthcheck failed")
return err
}
err := ws.HeartbeatLoop(ctx, conn, msgChan)
if err == io.EOF {
f.log.Info().Msg("healthcheck finished")
} else if errors.Is(err, context.Canceled) {
f.log.Info().Msg("healthcheck canceled")
} else {
f.log.Error().Err(err).Msg("healthcheck failed")
}
return nil
return err
})

g.Go(func() error {
Expand All @@ -262,9 +259,8 @@ func (f *FC2) HandleWS(
f.log.Info().Msg("ws listen canceled")
} else {
f.log.Error().Err(err).Msg("ws listen failed")
return err
}
return nil
return err
})

g.Go(func() error {
Expand All @@ -283,14 +279,12 @@ func (f *FC2) HandleWS(
}
if err == io.EOF {
f.log.Info().Msg("download stream finished")
return err
} else if errors.Is(err, context.Canceled) {
f.log.Info().Msg("download stream canceled")
} else {
f.log.Error().Err(err).Msg("download stream failed")
return err
}
return nil
return err
})

if f.params.WriteChat {
Expand All @@ -304,14 +298,12 @@ func (f *FC2) HandleWS(

if err == io.EOF {
f.log.Info().Msg("download chat finished")
return err
} else if errors.Is(err, context.Canceled) {
f.log.Info().Msg("download chat canceled")
} else {
f.log.Error().Err(err).Msg("download chat failed")
return err
}
return nil
return err
})
}

Expand Down

0 comments on commit 8ee0fd8

Please sign in to comment.