fix: no error on normal websocket closure
- ignore error for normal closure
- log any other errors encountered during message processing
- reorder import statements
🤖
This commit is contained in:
parent
7120877242
commit
6857615585
1 changed files with 7 additions and 2 deletions
|
@ -1,10 +1,10 @@
|
||||||
package websocket
|
package websocket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.smsvc.net/pomodoro/ChronoTomato/internal/notifications"
|
|
||||||
"git.smsvc.net/pomodoro/ChronoTomato/internal/shared"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/notifications"
|
||||||
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/shared"
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
@ -18,6 +18,11 @@ func ProcessServerMessages(conn *websocket.Conn) {
|
||||||
for {
|
for {
|
||||||
_, message, err := conn.ReadMessage()
|
_, message, err := conn.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if websocket.IsCloseError(err, 1000) {
|
||||||
|
// Ignore normal closure and exit gracefully
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Log any other errors
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
log.Error("Read error!", "reason", err)
|
log.Error("Read error!", "reason", err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue