alexandrevicenzi / go-sse

Server-Sent Events for Go
MIT License
172 stars 40 forks source link

panic on graceful shutdown #24

Open tc-hib opened 3 years ago

tc-hib commented 3 years ago

Hello, when using the Shutdown method, I get a panic:

panic: send on closed channel

This is because the removeClient channel is closed before all HTTP handlers got closed.

I am a beginner, but to me it looks like we should never close removeClient. But it will allow a goroutine leak, since goroutines trying to send on this channel will remain blocked.

I'll try to post a PR.

alexandrevicenzi commented 3 years ago

Share the code that you have, there are tests covering this area, it should work.

tc-hib commented 3 years ago

Hello, thanks for answering so quickly. In my PR the test reproduces the panic. I'm new to all this git stuff, sorry, I should have committed the test separately from the fix.

Jbaukens commented 2 years ago

Hello, hope u are doing well

Is there eventually any update about this ? I am getting each time i do a ctrl+c a panic when calling shutdown like above stated

Regards

alexandrevicenzi commented 2 years ago

Yes, there's going to be a fix, I was working on it, but right now I don't have time to continue it.