anmonteiro / anmonteiro/httpun-ws
`Eio.Switch.run` hangs cleaning up resources of failed websocket connection
- Lingua principale
- OCaml
- Stelle
- 29
- Fork
- 16
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Using the wscat example modified to resolve the promise on error, and with some extra logging:
```diff
diff --git a/examples/eio/wscat.ml b/examples/eio/wscat.ml
index ad6b645..573872e 100644
--- a/examples/eio/wscat.ml
+++ b/examples/eio/wscat.ml
@@ -30,9 +30,10 @@ let websocket_handler env ~sw u wsd =
; eof
}
-let error_handler = function
+let error_handler u = function
| `Handshake_failure (rsp, _body) ->
- Format.eprintf "Handshake failure: %a\n%!" Httpun.Response.pp_hum rsp
+ Format.eprintf "Handshake failure: %a\n%!" Httpun.Response.pp_hum rsp;
+ Promise.resolve u ();
| _ -> assert false
let () =
@@ -78,7 +79,11 @@ let () =
~host
~port
~resource
- ~error_handler
+ ~error_handler:(error_handler u)
~websocket_handler:(websocket_handler env ~sw u)
in
- Promise.await p))
+ Promise.await p;
+ Format.eprintf "After Promise.await\n%!"
+ );
+ Format.eprintf "After Switch.run\n%!"
+ )
```
With a random server that doesn't accept websocket connections, the promise resolves, but the `Eio.Switch.run` never returns (presumable because there are hanging fibers):
```
% dune exec ./examples/eio/wscat.exe 136.244.81.69
Handshake failure: ((version "HTTP/1.1") (status 404) (reason "Not Found") (headers
(("Date" "Tue, 10 Sep 2024 23:04:03 GMT")
("Content-Type" "text/html; charset=utf-8")("Content-Length" "146")
("Connection" "keep-alive"))))
After Promise.await
```
Note that `websocket_handler` is never called, so I don't think it's the input reading loop.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.