Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Classify normal WebSocket shutdowns as informational
[email protected]e21a3c443491
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 52cda5f0a4..690ae81c42 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -20,6 +20,11 @@## Purpose+Browser WebSocket shutdown distinguishes ordinary client lifecycle from+transport failure. Normal closure, navigation/going-away, and abnormal closure+codes used by disconnected clients are informational; policy violations and+other unexpected codes remain error-classified for operator visibility.+Successful quick security setup is durable before its success response isemitted: Pulse writes the canonical auth environment file, activates the samehashed credentials in memory, and for root systemd installs reports both thediff --git a/internal/websocket/hub.go b/internal/websocket/hub.goindex 84b9c59250..7c07ff1e63 100644--- a/internal/websocket/hub.go+++ b/internal/websocket/hub.go@@ -1783,6 +1783,15 @@ func (h *Hub) sendPing() {h.BroadcastMessage(msg)}+func isUnexpectedClientClose(err error) bool {+ return websocket.IsUnexpectedCloseError(+ err,+ websocket.CloseNormalClosure,+ websocket.CloseGoingAway,+ websocket.CloseAbnormalClosure,+ )+}+// readPump handles incoming messages from the clientfunc (c *Client) readPump() {defer func() {@@ -1810,7 +1819,7 @@ func (c *Client) readPump() {for {_, message, err := c.conn.ReadMessage()if err != nil {- if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {+ if isUnexpectedClientClose(err) {log.Error().Err(err).Str("client", c.id).Msg("webSocket read error")} else {log.Info().Err(err).Str("client", c.id).Msg("webSocket closed")diff --git a/internal/websocket/hub_test.go b/internal/websocket/hub_test.goindex d191423d3b..9dd250bec7 100644--- a/internal/websocket/hub_test.go+++ b/internal/websocket/hub_test.go@@ -9,9 +9,28 @@ import ("testing""time"+ gorillawebsocket "github.com/gorilla/websocket""github.com/rcourtman/pulse-go-rewrite/internal/alerts")+func TestNormalClientCloseIsNotAnError(t *testing.T) {+ normal := &gorillawebsocket.CloseError{+ Code: gorillawebsocket.CloseNormalClosure,+ Text: "Component unmounting",+ }+ if isUnexpectedClientClose(normal) {+ t.Fatal("normal component unmount was classified as an unexpected close")+ }++ policyViolation := &gorillawebsocket.CloseError{+ Code: gorillawebsocket.ClosePolicyViolation,+ Text: "authentication failed",+ }+ if !isUnexpectedClientClose(policyViolation) {+ t.Fatal("policy violation was not classified as an unexpected close")+ }+}+func TestClientSafeSendAndCloseAreSynchronized(t *testing.T) {client := &Client{send: make(chan []byte, 1)}start := make(chan struct{})