Closed
Description
This code:
w.targetsWatcher, err = gitwatch.New(
context.TODO(),
targetRepos,
w.checkInterval,
w.directory,
nil,
false)
if err != nil {
return errors.Wrap(err, "failed to watch targets")
}
go func() {
e := w.targetsWatcher.Run()
if e != nil && !errors.Is(e, context.Canceled) {
w.errors <- e
}
}()
zap.L().Debug("created targets watcher, awaiting setup")
<-w.targetsWatcher.InitialDone
zap.L().Debug("targets watcher initialised")
Is terrible. It was a quick solution but it really should be better.
If the targetsWatcher
fails in any way, it pushes errors to an error channel. But, if it never sends the InitialDone signal, the select on w.errors
never actually yields - deadlock.
This should instead be a select over the initial wait and the error channel that returns the error.
Metadata
Metadata
Assignees
Labels
No labels