Skip to content

Commit d3c91dc

Browse files
philippgillembobakov
authored andcommitted
Fix possible panic in goroutine
1 parent 90fd381 commit d3c91dc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

consul.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ func watchConsulService(ctx context.Context, s servicer, tgt target, out chan<-
101101
case ee := <-res:
102102
out <- ee
103103
case <-ctx.Done():
104+
// Close quit so the goroutine returns and doesn't leak.
105+
// Do NOT close res because that can lead to panics in the goroutine.
106+
// res will be garbage collected at some point.
104107
close(quit)
105-
close(res)
106108
return
107109
}
108110
}

0 commit comments

Comments
 (0)