I was debugging a nasty bug at $WORK, and to my surprise I found out that ZIO#onDone forks the effect and "discards" the fiber, running the success/error callbacks on exit (see here)
I think this behaviour is quite dangerous because its behaviour is very different than other onX methods (e.g., onExit). As a user (or in my case, when I reviewed the PR that caused the bug), I won't know that the method forks the effect and doesn't await on its completion unless I take a look at the source code.
In order to guard against incorrect usage of this method, we should consider deprecating it (onDoneCause as well). If we find out that users do use this method in the correct way and need it, we can introduce it under a more accurate name (forkDaemonExit or something)
I was debugging a nasty bug at $WORK, and to my surprise I found out that
ZIO#onDoneforks the effect and "discards" the fiber, running the success/error callbacks on exit (see here)I think this behaviour is quite dangerous because its behaviour is very different than other
onXmethods (e.g.,onExit). As a user (or in my case, when I reviewed the PR that caused the bug), I won't know that the method forks the effect and doesn't await on its completion unless I take a look at the source code.In order to guard against incorrect usage of this method, we should consider deprecating it (
onDoneCauseas well). If we find out that users do use this method in the correct way and need it, we can introduce it under a more accurate name (forkDaemonExitor something)