micro / plugins

Go Micro plugins
Apache License 2.0
96 stars 92 forks source link

kubernetes registry: do not send to closed channel #113

Closed butonic closed 1 year ago

butonic commented 1 year ago

Under heavy request load we encounter this panic:

panic: send on closed channel

goroutine 44488 [running]:
github.com/go-micro/plugins/v4/registry/kubernetes/client/watch.(*bodyWatcher).stream.func2()
    github.com/go-micro/plugins/v4/registry/kubernetes@v1.1.1/client/watch/body.go:72 +0x1ab
created by github.com/go-micro/plugins/v4/registry/kubernetes/client/watch.(*bodyWatcher).stream
    github.com/go-micro/plugins/v4/registry/kubernetes@v1.1.1/client/watch/body.go:51 +0x23b

With this PR we no longer see this panic.

AFAICT this is caused by closign the channel at the wrong time. Channels are rather unmapped territory for me, so let me know if this is the proper solution.