Skip to content

Handle fatal Errors in WebSocketClient read loop - #1510

Open
liyifan9642-creator wants to merge 5 commits into
TooTallNate:masterfrom
liyifan9642-creator:fix/client-fatal-error-1460
Open

liyifan9642-creator wants to merge 5 commits into
TooTallNate:masterfrom
liyifan9642-creator:fix/client-fatal-error-1460

Conversation

@liyifan9642-creator

Copy link
Copy Markdown

Summary

Closes #1460.

WebSocketImpl#decodeFrames rethrows fatal Errors (VirtualMachineError, ThreadDeath, LinkageError). The client read loop in WebSocketClient#run only caught IOException and RuntimeException, so such a fatal Error escaped run() and silently terminated the connect/read thread: no onError, no onClose, and no cleanup, leaving the socket half-open. The server-side WebSocketWorker already handles this (see #1223); this change brings the client to parity.

Changes

  • Catch the same fatal trio in the client read loop, surface it through onError (wrapped, as elsewhere) and close the connection with CloseFrame.UNEXPECTED_CONDITION (1011).
  • Add Issue1460Test, which uses a custom Draft that throws a LinkageError during translateFrame. The test fails before the change (no callbacks, thread dies) and passes after.

Notes

  • Single-file production change; no public API change; normal I/O and protocol paths are untouched.
  • Happy to adjust if maintainers would prefer a VirtualMachineError to be rethrown after cleanup instead.

@changeset-bot

changeset-bot Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: aed1160

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

This branch has not been deployed

No deployments
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.

unhandled Throwable in WebSocketClient

1 participant