Async_js exceptions silently dropped

I am trying:



         Async_js.init ();
         Async_kernel.don't_wait_for(
           let t = Async_kernel.try_with (Index.start_index_js) in
           Firebug.console##log "### halted";
           let%bind _ = begin
             match%map t with
             | Ok () -> 
               Firebug.console##log "Ok"; ()
             | Error err -> 
               Firebug.console##log "Err";
               Firebug.console##log err ; ()
           end in
           Firebug.console##log "### done printing";
           return ()
         )

But my exceptions are being silently dropped. Is there something else I need to do in my async js setup to have it dump exceptions / raise / failwith to the Chrome dev console ?

I tried your code out, and exceptions are being dumped to the chrome dev console (as well as being dumped in node). Eg:

open! Core
open! Async_kernel

let f : unit -> unit Deferred.t = fun () -> failwith "oops"

let () =
  Async_js.init () ;
  Async_kernel.don't_wait_for
    (let t = Async_kernel.try_with f in
     Js_of_ocaml.Firebug.console##log "### halted" ;
     let%bind _ =
       match%map t with
       | Ok () ->
           Js_of_ocaml.Firebug.console##log "Ok" ;
           ()
       | Error err ->
           Js_of_ocaml.Firebug.console##log "Err" ;
           Js_of_ocaml.Firebug.console##log err ;
           ()
     in
     Js_of_ocaml.Firebug.console##log "### done printing" ;
     return () )

Output:

Edit: (That’s with v0.15.1 of async_js and v0.15.0 of async_kernel)

1 Like

Maybe it is something weird in this function…that is different than the simple one I used as an example.

1 Like
  1. Thanks for sanity checking w/ an obvious raise/failwith. I should have done that earlier.

  2. Yeah, this is my fault, error is in code NOT shown in snippet above.