stefanprodan / podinfo

Go microservice template for Kubernetes
Apache License 2.0
5.4k stars 1.72k forks source link

podinfo crashes with panic when the WebSocket endpoint is under load #363

Closed rodrigorfk closed 5 months ago

rodrigorfk commented 5 months ago

Hi there, first of all, thank you very much for providing this project and keeping it active.

I was using podinfo as target for some WebSocket related load testing, and I have received some random panics when under having load as following:

panic: send on closed channel

goroutine 6574 [running]:
github.com/stefanprodan/podinfo/pkg/api/http.(*Server).sendHostWs(0x40000305f0, 0x89154?, 0x400685e4e0, 0x400685e300)
    /podinfo/pkg/api/http/echows.go:70 +0xcc
created by github.com/stefanprodan/podinfo/pkg/api/http.(*Server).echoWsHandler in goroutine 6582
    /podinfo/pkg/api/http/echows.go:37 +0x29c

which means that in some edge cases, the timer in the code below, is trying to write after the channel was already closed: https://github.com/stefanprodan/podinfo/blob/f3506240479e9263db500e67d8bb8908e52fc2d1/pkg/api/http/echows.go#L57-L76