You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2021-12-09T17:18:30.869187693Z: start
2021-12-09T17:18:33.897543168Z: finish
2021-12-09T17:18:33.899531757Z: use
2021-12-09T17:18:33.900238459Z: timeout
The "finish" message is still printed although the fiber is cancelled by timeoutTo. This is because the first FG.bracket call in bracketState code makes its init block uncancellable. The "commit" message is not printed because bracketCase calls it in the use block of the first FG.bracket, but it is not guaranteed that use will be executed after successful init.
This behavior breaks bracketModify and MVar-based tofu.memo.Cached.
The text was updated successfully, but these errors were encountered:
Yeah, that one is tricky.
This can be easily achieved with ZIO and CE3 but can be tricky in CE2 since it doesn't privide use result for the finalizer the bracket signature
My thoughts on how and when we fix this. This PR moves tofu.concurrent.Exit to the kernel. After that that way we can use Finally[F, tofu.concurrent.Exit] as a common interface for all three. Next, we can use it in the fixed bracketState version implementing it as a single bracket call.
We need to implement this common Finally thing for all three effects. CE2 version would have some dirty Ref hack to store use results, but it should do the trick.
The current implementation of
bracketState
does not guarantee that:use
will be cancelled when fiber is cancelledcommit
will be executed iffa
succeedsThe following code demonstrates the problem:
The output looks like this:
The "finish" message is still printed although the fiber is cancelled by
timeoutTo
. This is because the firstFG.bracket
call inbracketState
code makes itsinit
block uncancellable. The "commit" message is not printed becausebracketCase
calls it in theuse
block of the firstFG.bracket
, but it is not guaranteed thatuse
will be executed after successfulinit
.This behavior breaks
bracketModify
andMVar
-basedtofu.memo.Cached
.The text was updated successfully, but these errors were encountered: