rawhat / mist

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

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

Closed eliknebel closed 1 year ago

eliknebel commented 1 year 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