diff --git a/sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart b/sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart index 6dd9546a7a6..ab5022325f3 100644 --- a/sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart +++ b/sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart @@ -305,10 +305,7 @@ class _AsyncStarImpl { // already be scheduled. This will cause at least one more iteration to // run (adding another data item to the Stream) before actually pausing. // It could be fixed by moving the `isPaused` check inside `runBody`. - if (isScheduled || - controller.isPaused || - isSuspendedAtYieldStar || - isSuspendedAtAwait) { + if (isScheduled || controller.isPaused || isSuspendedAtYieldStar) { return; } isScheduled = true; diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/async_patch.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/async_patch.dart index 64f39835ef6..b80c74e8975 100644 --- a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/async_patch.dart +++ b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/async_patch.dart @@ -303,10 +303,7 @@ class _AsyncStarImpl { // already be scheduled. This will cause at least one more iteration to // run (adding another data item to the Stream) before actually pausing. // It could be fixed by moving the `isPaused` check inside `runBody`. - if (isScheduled || - controller.isPaused || - isSuspendedAtYieldStar || - isSuspendedAtAwait) { + if (isScheduled || controller.isPaused || isSuspendedAtYieldStar) { return; } isScheduled = true; diff --git a/tests/language/async_star/yield_from_catch_test.dart b/tests/language/async_star/yield_from_catch_test.dart new file mode 100644 index 00000000000..0f08c1fb254 --- /dev/null +++ b/tests/language/async_star/yield_from_catch_test.dart @@ -0,0 +1,33 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test for issue: https://github.com/dart-lang/sdk/issues/39994 + +import "dart:async"; +import "package:expect/expect.dart"; +import "package:async_helper/async_helper.dart"; + +Stream testStream() async* { + try { + await testThrow(); + yield "A"; + } catch (e) { + yield "B"; + yield "C"; + yield "D"; + } +} + +testThrow() async { + throw Exception(); +} + +test() async { + var result = await testStream().toList(); + Expect.listEquals(["B", "C", "D"], result); +} + +main() { + asyncTest(test); +} diff --git a/tests/language_2/async_star/yield_from_catch_test.dart b/tests/language_2/async_star/yield_from_catch_test.dart new file mode 100644 index 00000000000..0f08c1fb254 --- /dev/null +++ b/tests/language_2/async_star/yield_from_catch_test.dart @@ -0,0 +1,33 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test for issue: https://github.com/dart-lang/sdk/issues/39994 + +import "dart:async"; +import "package:expect/expect.dart"; +import "package:async_helper/async_helper.dart"; + +Stream testStream() async* { + try { + await testThrow(); + yield "A"; + } catch (e) { + yield "B"; + yield "C"; + yield "D"; + } +} + +testThrow() async { + throw Exception(); +} + +test() async { + var result = await testStream().toList(); + Expect.listEquals(["B", "C", "D"], result); +} + +main() { + asyncTest(test); +}