mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:47:13 +00:00
106d6b0ca5
This happened using APIs like `Stream.first` that set cancelOnError when they called `Stream.listen()`. If an error is signaled, Stream internals will call `cancel()` and wait for that future to complete before sending the error to the resulting Future. However the `async*` implementation class did not properly account for that possiblity, and never completed the cancellation future in that case. Change-Id: Ieaa35e56ee80208d7946904ea40bfd5f785ef9d6 Reviewed-on: https://dart-review.googlesource.com/c/83467 Commit-Queue: Alan Knight <alanknight@google.com> Auto-Submit: Jenny Messerly <jmesserly@google.com> Reviewed-by: Alan Knight <alanknight@google.com>
34 lines
879 B
Dart
34 lines
879 B
Dart
// Copyright (c) 2018, 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.
|
|
|
|
import "dart:async";
|
|
import "package:expect/async_minitest.dart";
|
|
|
|
/// Tests for exceptions raised in async*
|
|
main() {
|
|
test('async* with Stream.first should complete with an error', () async {
|
|
var expectedStack;
|
|
Stream<int> foo() async* {
|
|
try {
|
|
throw 'oops';
|
|
} catch (e, s) {
|
|
expectedStack = s;
|
|
try {
|
|
throw 'oops again!';
|
|
} catch (e2, _) {}
|
|
await new Future.error(e, s);
|
|
}
|
|
yield 42;
|
|
}
|
|
|
|
try {
|
|
await foo().first;
|
|
fail('should not get here, an error should be thrown');
|
|
} catch (e, s) {
|
|
expect(e, 'oops');
|
|
expect(s, expectedStack);
|
|
}
|
|
});
|
|
}
|