Skip to content

Commit

Permalink
fix: broke select in stream retrier
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Oct 26, 2023
1 parent f60aba9 commit 41e4cd8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/common/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ func RetryStreamingClientStream[Req, Resp any](
logger.Infof("Stream recovered")
errored = false
}
if _, ok := <-ctx.Done(); ok {
select {
case <-ctx.Done():
return
default:
}
retry.Reset()
logLevel = log.Warn
Expand All @@ -167,8 +169,12 @@ func RetryStreamingClientStream[Req, Resp any](
errored = true
delay := retry.Duration()
logger.Logf(logLevel, "Stream handler failed, retrying in %s: %s", delay, err)
if _, ok := <-ctx.Done(); ok {
select {
case <-ctx.Done():
return

case <-time.After(delay):
}

}
}

0 comments on commit 41e4cd8

Please sign in to comment.