open! Js_of_ocaml open! Hello (* https://stackoverflow.com/questions/34929382/what-are-the-differences-between-lwt-async-and-lwt-main-run-on-ocaml-node-js *) let rec run t = let next_tick (_callback : unit -> unit) = Js.Unsafe.(fun_call (js_expr "process.nextTick") [| inject (Js.wrap_callback _callback) |]) in Lwt.wakeup_paused (); match Lwt.poll t with | Some x -> x | None -> if Lwt.paused_count () > 0 then next_tick (fun () -> run t) else () let () = run @@ Hello.main