Repository navigation
Fix ParallelWaitError in forEachIsolateHelper during service disconnect - #10074
Merged
Merged
Conversation
`forEachIsolateHelper` used `[for (final isolate in vmIsolates) callback(isolate)].wait`. In Dart 3, the `Iterable.wait` extension wraps any error from completed futures in a `ParallelWaitError<V, E>`. When a target application exits or a VM Service connection is shut down while an operation is in flight (e.g. periodic polling in `refreshNetworkData`), VM Service methods like `getSocketProfileWrapper` throw `RPCError: (112) Service has disappeared`. Callers catch typed errors (e.g., `on RPCError catch (e)` in `network_service.dart` or `on SentinelException` / `on RPCError` in `service_extension_manager.dart`) and check `e.isServiceDisposedError` to safely swallow teardown exceptions. Because `ParallelWaitError` does not inherit from `RPCError` or `Exception`, it bypassed these typed catch blocks and escaped uncaught, causing flaky integration test failures in `network_screen_test.dart`. Using `Future.wait` preserves the underlying exception type thrown by the isolate callback. Also update `_enableNetworkTrafficRecordingOnAllIsolates` to use `Future.wait`.
Contributor
There was a problem hiding this comment.
Code Review
This pull request replaces the use of the .wait extension on lists of futures with Future.wait in _enableNetworkTrafficRecordingOnAllIsolates and forEachIsolateHelper. This ensures that isolate callback exceptions (such as RPCError or SentinelException) are rethrown directly instead of being wrapped in a ParallelWaitError. Unit tests have been added to verify this behavior, and the changelog has been updated. I have no feedback to provide on these changes.
johnpryan
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
forEachIsolateHelperused[for (final isolate in vmIsolates) callback(isolate)].wait. In Dart 3, theIterable.waitextension wraps any error from completed futures in aParallelWaitError<V, E>.When a target application exits or a VM Service connection is shut down while an operation is in flight (e.g. periodic polling in
refreshNetworkData), VM Service methods likegetSocketProfileWrapperthrowRPCError: (112) Service has disappeared. Callers catch typed errors (e.g.,on RPCError catch (e)innetwork_service.dartoron SentinelException/on RPCErrorinservice_extension_manager.dart) and checke.isServiceDisposedErrorto safely swallow teardown exceptions.Because
ParallelWaitErrordoes not inherit fromRPCErrororException, it bypassed these typed catch blocks and escaped uncaught, causing flaky integration test failures innetwork_screen_test.dart. See this log.Using
Future.waitpreserves the underlying exception type thrown by the isolate callback. Also update_enableNetworkTrafficRecordingOnAllIsolatesto useFuture.wait.