-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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.fromIterable doesn't handle errors during iteration well #33431
Comments
This seems working as intended. From the Doc comment on the constructor:
|
This was changed here: 781e842#diff-5a9c317c5de11a5a7ab7a39c97e76a90R517 Before that it looks like the stream was closed on error. Nothing in the commit message or the review mention why this decision was made. @lrhn could maybe add some context on that. |
Reopening – seems really weird that final print is not called, but there is no error and the exit code is still 0. |
See this test case - https://gist.github.com/kevmoo/c51dbeedb9091052d36b193432fea87f
@natebosch – thanks for your digging! |
The "safe" behavior makes so much more sense to me. Having the Stream end w/ the first error is much easier to deal with... |
@mraleph – FYI re our chat before lunch |
The issue of the VM terminating in the middle of an async method is not new (#23797). I'm willing to reconsider the behavior for The issue here is that sending a done event has a meaning - the stream is complete. It's not the same as there being no further events, although that's obviously implied. Which makes me ask: Is this an actual issue, separate from the VM terminating? That is, if the VM hung instead, would that be enough? Is this occurring in actual code, and not just toy examples? If we change it, one option is to keep iterating after a throw. That allows each call to The other alternative is to always send a done event after the error event. If code ignores the error, it might think that the input is actually complete, but then, if you ignore an error in your data source, you should probably not trust the result anyway. |
I'd say error out after the first error – on current, moveNext, By the law of least surprise, I'd assume that running over Stream<int> _badStream() async* {
yield 1;
yield 2;
throw 'no 3!';
}
Iterable<int> _badIterable() sync* {
yield 1;
yield 2;
throw 'no 3!';
} |
I'm trying an implementation where a throwing That should let the example above have identical behavior - the throw in the |
@lrhn – did this get fixed? |
If an error is throw, it's not caught. The app just seems to exit with 0 without
done
being hit. Very weird.The sample code at the bottom has the following output:
Note: no
*** DONE ***
, notrue
printed at the bottom. The app just exits (with status 0).This is on -dev.61
CC @lrhn
The text was updated successfully, but these errors were encountered: