websocket
websocket copied to clipboard
fix: possible panic in client tests
What type of PR is this? (check all applicable)
- [ ] Refactor
- [ ] Feature
- [x] Bug Fix
- [ ] Optimization
- [ ] Documentation Update
- [ ] Go Version Update
- [ ] Dependency Update
Description
This PR fixes a possible panic in tests. When err is not nil in newWebsocketServer, websocketServer is nil, and defer websocketServer.Close() will panic. The same applies to the newProxyServer function.
Added/updated tests?
- [x] Yes
- [ ] No, and this is why: please replace this line with details on why tests have not been included
- [ ] I need help with writing tests
The change in this PR is good.
This panic is not the only problem with an error return from the function newWebsocketServer. The function newWebsocketServer leaks a listener when returning an error. That function should websocketServer.Close() when returning an error.