Skip to content

Fix CaseClauseError on WebSocket close frame - #86

Open
matthiaz wants to merge 1 commit into
CuatroElixir:mainfrom
matthiaz:fix-close-frame-crash
Open

Fix CaseClauseError on WebSocket close frame#86
matthiaz wants to merge 1 commit into
CuatroElixir:mainfrom
matthiaz:fix-close-frame-crash

Conversation

@matthiaz

@matthiaz matthiaz commented Aug 3, 2026

Copy link
Copy Markdown

Mint.WebSocket.stream/2 can return {:error, conn, %Mint.HTTPError{}, _} when the server sends a WebSocket close frame after the HTTP/1 request is already complete. The existing case clauses only matched Mint.TransportError, causing a CaseClauseError that crashes the connection process.

Add a catch-all {:error, conn, reason, _} clause that treats any unhandled error as a graceful ChannelClosed event, allowing the client to handle it via handle_disconnect/2.

Mint.WebSocket.stream/2 can return {:error, conn, %Mint.HTTPError{}, _}
when the server sends a WebSocket close frame after the HTTP/1 request
is already complete. The existing case clauses only matched
Mint.TransportError, causing a CaseClauseError that crashes the
connection process.

Add a catch-all {:error, conn, reason, _} clause that treats any
unhandled error as a graceful ChannelClosed event, allowing the client
to handle it via handle_disconnect/2.
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.

1 participant