Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/acceptor/ws_acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,18 @@ func NewWSConn(conn *websocket.Conn) (*WSConn, error) {
return c, nil
}

// IsNotWsError
func (c *WSConn) IsNotWsError(err error) bool {
// Ignore normal closure errors
// 1000: Normal closure
// 1001: Going away
return !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway)
}

// GetNextMessage reads the next message available in the stream
func (c *WSConn) GetNextMessage() (b []byte, err error) {
_, msgBytes, err := c.conn.ReadMessage()
if err != nil {
if err != nil && c.IsNotWsError(err) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal closure becomes misleading invalid header error

High Severity

The IsNotWsError check prevents GetNextMessage from returning normal websocket close errors (1000/1001). Instead, it proceeds with an empty message, returning packet.ErrInvalidPomeloHeader. This causes the session handler to log an Errorf for normal client disconnects, which is contrary to the PR's goal of silent handling and diverges from the TCP acceptor's clean close behavior.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ae8e7aa. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the AI didn't see the internal implementation of the IsNotWsError method, which led to the opposite conclusion.

return nil, err
}
if len(msgBytes) < codec.HeadLength {
Expand Down
Loading