Open ul opened 10 months ago
I minimized this example (please do so! :)) to confirm that this is indeed an Lwt issue:
type _ Effect.t += E : unit Effect.t
let () =
Effect.Deep.try_with
begin fun () ->
Lwt_main.run begin
Lwt.bind (Lwt_unix.sleep 1.) @@ fun () ->
Effect.perform E;
assert false
end
end
()
{
effc = fun (type a) (e : a Effect.t) ->
match e with
| E ->
Option.some @@ fun (k : (a, _) Effect.Deep.continuation) ->
prerr_endline "handling E";
Effect.Deep.continue k ()
| _ -> None
}
I've opened https://github.com/ocsigen/lwt/issues/1003 to ask about it.
Consider the following snippet (it's not a strictly minimal example; I hope that's fine):
Making a
POST /api/users/login
request with a valid payload fails because the effect appears to be unhandled. As well as the following variation:Lwt seems at fault here, as moving
with_handlers
insidelet%lwt
or not parsing the request body at all works as expected with the second variation. Are there any tips on how to use Dream with some top-level effect handlers? Either by installing them in a way that works with Lwt or duplicating them more ergonomically than just carefully spotting all use of async API from Dream and manually inserting effect handler inside the promise handlers.