-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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.periodic usage causes test to hang #40074
Comments
The test flutter doctor -v
|
The issue still reproduces as of master 3.6 and stable 3.3 testimport 'dart:async';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('repro with testWidgets (hangs)', (tester) async {
final periodic = Stream<int>.periodic(const Duration(seconds: 10),(count)=>count);
final subscription = periodic.listen((x){
print('x: $x');
});
await tester.pump(const Duration(seconds: 3));
await subscription.cancel();
print('done');
});
} flutter doctor -v (mac)
|
@kentcb the issue has nothing to do with import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Periodic Stream - Working Fine (No Await)', (tester) async {
final periodic =
Stream<int>.periodic(const Duration(seconds: 30), (i) => i);
final subscription = periodic.listen(null);
await tester.pump(const Duration(seconds: 3));
//Note here that we don't await and the test passes fine
subscription.cancel();
});
testWidgets('Periodic Stream - Test Hangs (Await Cancel Subscription)', (tester) async {
final periodic =
Stream<int>.periodic(const Duration(seconds: 30), (i) => i);
final subscription = periodic.listen(null);
await tester.pump(const Duration(seconds: 3));
//Note here that you can step right over this line and it looks like it executes fine, but it will cause the test to hang
await subscription.cancel();
});
} |
I've been trying to get to the bottom of this issue and have honed in on
Stream.periodic
. In trying to diagnose, I've hit a (probably related) issue, per below.Steps to Reproduce
Running the
repro with quiver (works)
orrepro with fake_async package (works)
tests both work fine. But running therepro with testWidgets (hangs)
test will hang after test execution.Flutter Doctor
The text was updated successfully, but these errors were encountered: