Get rid of (most of) calls to `Lwt.async`
General context
From the Lwt documentation:
Lwt.async
is misleadingly named. Itself, it has nothing to do with asynchronous execution. It's actually a safety function for making Lwt programs more debuggable.
Specifically, Lwt.async
wraps a promise in a form of ignore
and an exception catching mechanism that delegates the handling to a hook registered by a side-effect-ful function.
Tezos-specific context
We use the handler system from Lwt.async
in the Lwt_exit
library (src/lib_stdlib_unix/lwt_exit.ml
). This sets the binaries to exit when an exception is thrown. This is the correct thing to do for some exceptions (e.g., the exceptions thrown by signal handlers), but it is not always desirable.
There are multiple occurences of Lwt.async
within the source code.
Problem
Some simple errors could cause a node to exit.
Solution
Provide a async-like mechanism and replace uses of Lwt.async
by said mechanism.