You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 668977b
Browse filesBrowse the repository at this point in the historyBrowse files
[flutter_tools] Guard socket streams and done futures against socket reset errors (flutter#192941)
When remote peers abruptly terminate or reset network connections, POSIX
event handlers (such as epoll) trigger low-level socket reset errors
(`SocketException: Error event raised in event handler : error condition
has been reset, port = 0`) via `_NativeSocket.multiplex`.
If these socket error events occur on streams or sink `done` futures
that lack error handlers, or when adding to/closing sinks in an error
state, the unhandled exception escapes into the Zone and causes Flutter
tool crashes.
This change:
- Introduces `FutureErrorHandling<T>` in
`packages/flutter_tools/lib/src/base/common.dart` to provide a reusable
`.handleError(...)` extension on `Future` for background futures without
requiring empty `(_) {}` callbacks.
- Guards `createVmServiceDelegate` channel streams, sink `done` futures,
and sink operations against `SocketException`.
- Guards `DaemonStreams.fromSocket`, `DaemonStreams.connect`, and daemon
server `socket.done` and `socket.addStream` futures.
- Adds `onError` handling to `ProxiedPortForwarder` forwarded socket
streams.
- Adds `onError` handling to `ResidentRunner` log streams.
- Adds error handling to `AndroidConsole` socket `done` future on
connect and destroy.
- Adds unit tests for `FutureErrorHandling.handleError` (including
`test` predicate filtering) and regression tests verifying that socket
stream and done future errors do not crash the tool.
Fixesflutter#192935
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
0 commit comments