rawhat / mist

gleam HTTP server. because it glistens on a web
Apache License 2.0
260 stars 11 forks source link

Ok(_) assertion in mist/internal/websocket.gleam crashes process #24

Closed eliknebel closed 9 months ago

eliknebel commented 9 months ago

When trying to use mist websockets across page reloads, guided by the readme example, mist seems to crash due to some issue related to connection.transport.send, but I am not sure why.

Removing the assertion on line mist/internal/websocket.gleam:232:

          let assert Ok(_) =
            connection.transport.send(
              connection.socket,
              frame_to_bit_builder(frame),
            )

changing to:

          let _ =
            connection.transport.send(
              connection.socket,
              frame_to_bit_builder(frame),
            )

fixes the issue, however I am not sure that is the correct fix or not. But by removing this assertion, the code is allowed to proceed with gracefully stopping the actor and prevents it from crashing the entire process, putting the website in an unrecoverable state.

This issue is reproducible in the following project: https://github.com/bitbldr/mist_ws_crash