Skip to content

All *_s combinators of Lwt_react eat exceptions silently #1101

@rand00

Description

@rand00

The E.*_s and S.*_s combinators all eat exceptions raised by the function-argument:

#!/usr/bin/env -S opam exec -- utop

#thread
#require "lwt"
#require "lwt.unix"
#require "lwt_react"

open Lwt.Syntax
open Lwt_react

let tick_e, tick_eupd = E.create ()
let tick_s = S.hold () tick_e

(*> Works*)
let e0 = tick_e |> E.map (fun _ -> failwith "error")

(*> No exception is printed - and program doesn't terminate*)
let e1 = tick_e |> E.map_s (fun _ -> failwith "error")

(*> Works*)
let e2 = tick_e |> E.map_p (fun _ -> failwith "error")
  
(*> No exception is printed - and program doesn't terminate*)
let e3 = tick_e |> E.fmap_s (fun _ -> failwith "error")

(*> No exception is printed - and program doesn't terminate*)
let s0 = tick_s |> S.map_s (fun _ -> failwith "error")

let rec feed_tick () = let* () = Lwt_unix.sleep 0.5 in tick_eupd (); feed_tick ()

let () = Lwt_main.run @@ loop () 

The exception is neither printed nor leading to program exit. From the source, this seems to be everywhere where Lwt_mutex.with_lock is used to wrap the given function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions