conn: drop ErrClosed workaround for WebSocket
The fix has been merged upstream.
This commit is contained in:
parent
c859d2134a
commit
47346b0f10
12
conn.go
12
conn.go
@ -76,18 +76,8 @@ func (wic *websocketIRCConn) WriteMessage(msg *irc.Message) error {
|
|||||||
return wic.conn.Write(ctx, websocket.MessageText, b)
|
return wic.conn.Write(ctx, websocket.MessageText, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isErrWebSocketClosed(err error) bool {
|
|
||||||
return err != nil && strings.HasSuffix(err.Error(), "failed to close WebSocket: already wrote close")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wic *websocketIRCConn) Close() error {
|
func (wic *websocketIRCConn) Close() error {
|
||||||
err := wic.conn.Close(websocket.StatusNormalClosure, "")
|
return wic.conn.Close(websocket.StatusNormalClosure, "")
|
||||||
// TODO: remove once this PR is merged:
|
|
||||||
// https://github.com/nhooyr/websocket/pull/303
|
|
||||||
if isErrWebSocketClosed(err) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wic *websocketIRCConn) SetReadDeadline(t time.Time) error {
|
func (wic *websocketIRCConn) SetReadDeadline(t time.Time) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user