-
Notifications
You must be signed in to change notification settings - Fork 603
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
Unreliable stream interruption #2330
Comments
@njwilson23 Good afternoon, Nat. Thanks for reporting this bug. We will try to look at it as soon as we can. In the meantime, to help us with testing, could you submit this as an executable |
Sure, PR opened. I did my testing on 2.5.0, although I've been tracking similar strangeness since at least 2.2.x. I'll try to get it working on 3.x and report back. |
I verified that it exhibits the same surprising behaviour with scalaVersion := "2.13.5"
libraryDependencies += "org.typelevel" %% "cats-core" % "2.4.2"
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.0.0-RC2"
libraryDependencies += "co.fs2" %% "fs2-core" % "3.0.0-M9" |
I have just been running the executable, in the PR you opened, on top of the current |
That's interesting and surprising! However, I tried changing the numbers slightly, requiring 100 interruptions (up from 10), and consuming 10,000 values (up from 1,000). That reproduces the flaky behaviour observed with previous versions, so it doesn't seem like it's fixed in a consistent manner. I'm also curious, what do we expect to happen? From a (superficial) reading of the code, I expected |
When a stream is interrupted, I expect based on these docs that the interruption is final and can only be handled with
Stream.bracket
(or something built onStream.bracket
).So, I would not expect the following code, which attempts to restart a stream indefinitely, to work when the provided stream is interrupted:
However, I find that it sometimes works, and sometimes doesn't. In the following test:
if I only interrupt the stream a small number of times (e.g. once), most likely the
restart
function works and I get the 1000 elements from.take
. But if I allow many interruptions (e.g. 10), typically the stream I get is truncated.This is very surprising! Is this nondeterminism a bug?
The text was updated successfully, but these errors were encountered: