-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix soundness issue with stream interruption + translation #2145
Conversation
One option is adding a private |
that means we will be back to every concurrent stream combinator, and therefore pretty much the whole stack, requiring Async again :( |
I found a better fix, basically |
OK, I pushed a sketch of the better fix. I need to get it compiling on 2.12 and then do something similar for the other operations on Scope, then finally delete getScope entirely. |
Alright, ready for review. I made |
Sketch of a fix for #2143, though not sure how to resolve the outstanding issues here.
The main issue is
Stream.getScope
:This operation provides a
Scope[F]
which provides various operations that returnF[X]
, likeinterrupt
. During stream evaluation, aCompileScope[G]
is created, whereG
is the target effect type. The problem here is thatgetScope
is implemented by returning the currentCompileScope[G]
and whenG != F
, we get class cast exceptions (becauseinterrupt
returns aG[Unit]
but caller thinks they have anF[Unit]
).The sketch of a solution in this PR introduces a new primitive,
Interrupt
, which invokes the interrupt operation on the currentCompileScope
. However, we have no mechanism to use this operation in the definition ofinterruptWhen
, as doing so requires concurrent stream evaluation viaconcurrently
ormerge
orparJoin
but those all useinterruptWhen
internally.