Repository navigation
Closed
Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testshas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
Steps to reproduce
(See the code example below).
- Set up a mock stream handler:
const kTestEventChannelName = 'binary_messenger_test';
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockStreamHandler(
EventChannel(kTestEventChannelName),
MockStreamHandler.inline(onListen: _onListen),
);- In the
onListenfor the stream (or whilst the stream is being listened to), callendOfStream:
void _onListen(
final Object? rawArguments,
final MockStreamHandlerEventSink events,
) {
events.endOfStream();
}- Listen to the stream:
EventChannel(
kTestEventChannelName,
).receiveBroadcastStream({'close': true}).listen((_) {});- Observe that the test hangs.
Expected results
The test should not hang.
Actual results
The test hangs. (Reproducible on stable 3.44.9 and the latest beta build 3.47.0-0.4.pre)
Code sample
Code sample
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('closure of MockStreamHandlerEventSink does not hang', () {
setUpAll(TestWidgetsFlutterBinding.ensureInitialized);
const kTestEventChannelName = 'binary_messenger_test';
setUp(() {
void _onListen(
final Object? rawArguments,
final MockStreamHandlerEventSink events,
) {
final arguments = rawArguments as Map<dynamic, dynamic>? ?? {};
final close = arguments['close'] as bool? ?? false;
if (close) {
events.endOfStream();
}
}
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockStreamHandler(
EventChannel(kTestEventChannelName),
MockStreamHandler.inline(onListen: _onListen),
);
});
testWidgets('test finishes without hanging when sink is not closed', (
final tester,
) async {
EventChannel(
kTestEventChannelName,
).receiveBroadcastStream({'close': false}).listen((_) {});
});
testWidgets('test finishes without hanging when sink is closed', (
final tester,
) async {
EventChannel(
kTestEventChannelName,
).receiveBroadcastStream({'close': true}).listen((_) {});
}, timeout: const Timeout(Duration(seconds: 1)));
});
}
Screenshots or Video
N/A
Logs
N/A
Flutter Doctor output
Doctor output
❯ flutter doctor -v
[✓] Flutter (Channel beta, 3.47.0-0.4.pre, on macOS 26.5.2 25F84 darwin-arm64, locale en-US) [984ms]
• Flutter version 3.47.0-0.4.pre on channel beta at /Users/samjakob/sdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 034409942b (4 days ago), 2026-08-04 19:31:03 -0700
• Engine revision f88005a259
• Dart version 3.13.0 (build 3.13.0-282.4.beta)
• DevTools version 2.60.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use,
enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,551ms]
• Android SDK at [REDACTED]
• Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
• Platform android-36.1, build-tools 36.0.0
• Java binary at: [REDACTED]
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.x.x [REDACTED])
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 26.6) [614ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17F113
! CocoaPods not installed.
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) [5ms]
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Connected device (1 available) [5.9s]
• macOS (desktop) • macos • darwin-arm64 • macOS 26.x.x [REDACTED] darwin-arm64
[✓] Network resources [448ms]
• All expected network resources are available.
! Doctor found issues in 2 categories.Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testshas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight
Activity
saurabh-mirajkar commentedon Aug 10, 2026
@SamJakob Thanks for the report. I was able to reproduce with provided test sample on both latest stable and current master. Routing this to further investigation.
stable
master
log
Work around flutter/flutter#190807 in the stub platform host
Do not wait again for a closed mock event stream in tear down (flutte…