Skip to content

Commit 53bda39

Browse files
zichanggcommit-bot@chromium.org
authored andcommitted
Create stream timeout timer before ondata() opeartions
Originally, Timer for timeout is created after controller.add() where onCancel has been triggered. Timeout events will always be called. Bug: #37565 Change-Id: I1504694cb746b6653d858effd7c5b33b07de6057 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109725 Reviewed-by: Lasse R.H. Nielsen <[email protected]> Commit-Queue: Zichang Guo <[email protected]>
1 parent 65d544e commit 53bda39

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sdk/lib/async/stream.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,11 @@ abstract class Stream<T> {
15611561

15621562
void onData(T event) {
15631563
timer.cancel();
1564-
controller.add(event);
15651564
timer = zone.createTimer(timeLimit, timeout);
1565+
// It might close the stream and cancel timer, so create recuring Timer
1566+
// before calling into add();
1567+
// issue: https://github.com/dart-lang/sdk/issues/37565
1568+
controller.add(event);
15661569
}
15671570

15681571
void onError(error, StackTrace stackTrace) {

0 commit comments

Comments
 (0)