Hello, and thanks for your work on this great package!
I have a strange (and critical!) issue. When using Dream.serve, if I send a long string to a closed connection, the program simply exits, without any error.
Here is a minimal reproduction:
- Create a server with
Dream.serve, which waits 3 seconds before answering a long string of as:
open Lwt.Syntax
let () =
let f =
let+ () =
Dream.serve
@@ Dream.logger (fun _ ->
Logs.app (fun m -> m "Starting waiting");
let* () = Lwt_unix.sleep 3.0 in
Logs.app (fun m -> m "Finished waiting");
let x = String.init 1015765 (fun _ -> 'a') in
Dream.respond x)
in
print_endline "Finished"
in
Lwt_main.run f
-
Start the program. Connect to localhost:8080 with a web browser, but close the tab before the 3 seconds elapses
-
Have a look at the log, and cry 😢:
$ dune exec ./middleware.exe
10.01.25 10:36:56.511 dream.logger INFO REQ 1 GET / ::1:48826 fd 6 Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/127.0
10.01.25 10:36:56.511 REQ 1 Starting waiting
10.01.25 10:36:59.515 REQ 1 Finished waiting
10.01.25 10:36:59.528 dream.logger INFO REQ 1 200 in 3017101 μs
$ # back to prompt. "Finished" was not even written to output... Error result is 0.
Some more comments:
-
Any length of answer above 1015765 result in this behavior,
-
Any length below works as expected
-
The same program but with Dream.run works!
open Lwt.Syntax
let () =
Dream.run
@@ Dream.logger (fun _ ->
Logs.app (fun m -> m "Starting waiting");
let* () = Lwt_unix.sleep 3.0 in
Logs.app (fun m -> m "Finished waiting");
let x = String.init 1015765 (* 1061514 *) (fun _ -> 'a') in
Dream.respond x)
I am puzzled...
Hello, and thanks for your work on this great package!
I have a strange (and critical!) issue. When using
Dream.serve, if I send a long string to a closed connection, the program simply exits, without any error.Here is a minimal reproduction:
Dream.serve, which waits 3 seconds before answering a long string ofas:Start the program. Connect to localhost:8080 with a web browser, but close the tab before the 3 seconds elapses
Have a look at the log, and cry 😢:
Some more comments:
Any length of answer above 1015765 result in this behavior,
Any length below works as expected
The same program but with
Dream.runworks!I am puzzled...