Skip to content

websocket: provide descriptive error on abnormal closure (fixes #4625)#4810

Open
M-YasirGhaffar wants to merge 1 commit intonodejs:mainfrom
M-YasirGhaffar:fix/websocket-1006-error-message
Open

websocket: provide descriptive error on abnormal closure (fixes #4625)#4810
M-YasirGhaffar wants to merge 1 commit intonodejs:mainfrom
M-YasirGhaffar:fix/websocket-1006-error-message

Conversation

@M-YasirGhaffar
Copy link

This relates to...

Fixes #4625

Rationale

When a WebSocket connection closes abnormally (code 1006) without completing the control frame exchange, the error event contained an empty TypeError message. This made debugging difficult as the error appeared cryptic with no description of what went wrong.

Changes

  • Modified lib/web/websocket/websocket.js line 590 to use a fallback message when reason is empty
  • Added test/websocket/issue-4625.js to verify the fix works for abnormal closures

Features

N/A

Bug Fixes

  • When WebSocket closes without receiving a close frame (code 1006), the error message now provides a descriptive fallback: "WebSocket connection closed abnormally" instead of an empty string

Breaking Changes and Deprecations

N/A

Status

…s#4625)

Signed-off-by: M-YasirGhaffar <yasirghaffar.nust@gmail.com>
@metcoder95 metcoder95 requested a review from KhafraDev February 6, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More Descriptive Error When WebSocket Closes with Code 1006

1 participant