piaf icon indicating copy to clipboard operation
piaf copied to clipboard

`Failure("hd")` and `Failure("cannot write to closed writer")` when websocket connections closes

Open copy opened this issue 1 year ago • 0 comments

To reproduce:

% dune exec examples/eio/echo_server_upgrade.exe
// run with `node file.js`
const ws = new WebSocket("ws://localhost:8080/");
ws.onopen = function()
{
    console.log("open");
    setTimeout(() => {
        console.log("close");
        ws.close();
    }, 1000);
};

The server outputs (with an ugly backtrace with Printexc.record_backtrace true):

echo_server_upgrade.exe: [INFO] Server listening on tcp:127.0.0.1:12345
echo_server_upgrade.exe: [ERROR] Error in connection handler: Multiple exceptions:
- Failure("hd")
- Failure("cannot write to closed writer")

It would be nice to handle a regular connection closing more gracefully.

copy avatar Dec 14 '24 00:12 copy