Skip to content
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

Stream.take(0) doesn't forward errors any more. #81

Closed
lrhn opened this issue Nov 4, 2016 · 2 comments
Closed

Stream.take(0) doesn't forward errors any more. #81

lrhn opened this issue Nov 4, 2016 · 2 comments
Assignees

Comments

@lrhn
Copy link
Member

lrhn commented Nov 4, 2016

We are fixing a bug in Stream.take with a zero count that made it not cancel the subscription immediately. It should, and now it does, which also means that two tests are now failing:

  • LibTest/async/Stream/take_A01_t02
  • LibTest/isolate/ReceivePort/take_A01_t02

Both seem to assume that .take(0) will still propagate an error event, which it now won't.

The description of Stream.take was a little confusing, and will also be cleaned up. It did say that the subscription was cancelled after [count] events had been received, which is now true even for count == 0.

@alsemenov
Copy link
Contributor

I think current description is still confusing:

Forwards the first n data events of this stream, and all error events, to the returned stream, and ends with a done event.

I conclude that error events are received without any restrictions.
If I understand correctly, the .take(0) works as follows:

StreamSubscription ss = stream.listen(...);
ss.cancel();

Is there a possibility, that between these lines the stream generates some error (in another thread for example) and this error is received?

alsemenov added a commit that referenced this issue Nov 21, 2016
alsemenov added a commit that referenced this issue Nov 21, 2016
@lrhn
Copy link
Member Author

lrhn commented Nov 21, 2016

The current documentation on the bleeding edge branch now says:

Provides at most the first [count] data events of this stream.

Forwards all events of this stream to the returned stream
until [count] data events have been forwarded or this stream ends,
then ends the returned stream with a done event.

If this stream produces fewer than [count] data events before it's done,
so will the returned stream.

Starts listening to this stream when the returned stream is listened to
and stops listening when the first [count] data events have been received.

This means that if this is a single-subscription (non-broadcast) streams
it cannot be reused after the returned stream has been listened to.

If this is a broadcast stream, the returned stream is a broadcast stream.
In that case, the events are only counted from the time
the returned stream is listened to.

I believe it will be published with the 1.21 release.

whesse added a commit to dart-lang/sdk that referenced this issue Nov 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants