Skip to content

Commit 3198ae9

Browse files
committed
[flutter_tools] Dispose ExtensionConnection on isolate exit and inline controller cleanup
- Delegate unexpected isolate exit handling in _handleIsolateExit to dispose() to centralize resource teardown. - Inline _closeNotificationControllers directly into dispose() as it is the single cleanup path. Part of flutter#190755 Part of flutter#190746
1 parent 27427aa commit 3198ae9

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

‎packages/flutter_tools/lib/src/experimental/extension_discovery.dart‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ class ExtensionConnection {
8181
/// closing active notification streams instead of hanging indefinitely.
8282
void _handleIsolateExit() {
8383
_logger.printTrace('Extension isolate "$extensionName" exited unexpectedly.');
84-
_errorPort.close();
85-
_exitPort.close();
86-
_receivePort.close();
87-
unawaited(_closeNotificationControllers());
84+
unawaited(dispose());
8885
}
8986

9087
/// Returns a broadcast stream of JSON-RPC 2.0 notifications sent by the
@@ -233,14 +230,6 @@ class ExtensionConnection {
233230
}
234231
}
235232

236-
Future<void> _closeNotificationControllers() async {
237-
for (final StreamController<Map<String, Object?>> controller
238-
in _notificationControllers.values) {
239-
await controller.close();
240-
}
241-
_notificationControllers.clear();
242-
}
243-
244233
/// Disposes the extension isolate connection.
245234
Future<void> dispose() async {
246235
if (_isDisposed) {
@@ -251,7 +240,11 @@ class ExtensionConnection {
251240
_errorPort.close();
252241
_exitPort.close();
253242
_receivePort.close();
254-
await _closeNotificationControllers();
243+
for (final StreamController<Map<String, Object?>> controller
244+
in _notificationControllers.values) {
245+
await controller.close();
246+
}
247+
_notificationControllers.clear();
255248
try {
256249
await _peer.close();
257250
} on Object catch (error) {

0 commit comments

Comments
 (0)