1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-01-05 19:57:02 +00:00

wsutil: Added graceful close checking

This commit is contained in:
diamondburned 2020-10-30 13:54:26 -07:00
parent 607250ae55
commit 63310fdc95

View file

@ -6,6 +6,7 @@ import (
"context"
"io"
"net/http"
"strings"
"time"
"github.com/gorilla/websocket"
@ -167,6 +168,12 @@ func startReadLoop(conn *websocket.Conn, eventCh chan<- Event) {
return
}
// Is the error an intentional close call? Go 1.16 exposes
// ErrClosing, but we have to do this for now.
if strings.HasSuffix(err.Error(), "use of closed network connection") {
return
}
// Check if the error is a normal one:
if websocket.IsCloseError(err, websocket.CloseNormalClosure) {
return