refactor: nodes analytics (#847)

* refactor: nodes analytics

* feat(debug): add pprof in debug mode

* refactor: websocket error handler
This commit is contained in:
Jacky 2025-02-05 17:25:29 +08:00
parent b1ba719cb1
commit cb4977e5ab
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
17 changed files with 276 additions and 155 deletions

View file

@ -1,24 +1,21 @@
package helper
import (
"strings"
"github.com/gorilla/websocket"
"errors"
"github.com/gorilla/websocket"
"strings"
"syscall"
)
// IsUnexpectedWebsocketError checks if the error is an unexpected websocket error
func IsUnexpectedWebsocketError(err error) bool {
// nil error is an expected error
if err == nil {
return false
}
// ignore: write: broken pipe
if errors.Is(err, syscall.EPIPE) {
return false
}
// client closed error: *net.OpErr
if strings.Contains(err.Error(), "An existing connection was forcibly closed by the remote host") {
return true
return false
}
return websocket.IsUnexpectedCloseError(err,