Closed as not planned
Description
Generator function marked as async*
performs excessive generation cicle after resume()
Example:
import "dart:async";
List<int> readyToSent = [];
List<int> sent = [];
Stream<int> generator() async* {
for (int i = 1; i <= 5; i++) {
readyToSent.add(i);
yield i;
sent.add(i);
}
}
main() async {
List received = [];
Stream<int> s = generator();
late StreamSubscription<int> ss;
ss = s.listen((int i) async {
received.add(i);
if (i == 2) {
print(sent); // [1]
print(readyToSent); // [1, 2]
ss.pause();
await Future.delayed(Duration(milliseconds: 100));
print(sent); // [1]
print(readyToSent); // [1,2]
ss.resume();
print(sent); // [1]
print(readyToSent); // [1, 2]
ss.pause();
await Future.delayed(Duration(milliseconds: 100));
print(sent); // [1, 2] Why?
print(readyToSent); // [1, 2, 3]
await ss.cancel();
}
});
await Future.delayed(Duration(seconds: 1));
print("F1: $received"); // [1, 2]
print("F2: $sent"); // [1, 2]
print("F3: $readyToSent"); // [1, 2, 3]
}
Tested on the edge version of SDK on Linux
Cc @lrhn