Repository navigation
[flutter_tools] Add JSON-RPC notification support and post-handshake isolate exit handling to ExtensionConnection - #194961
Merged
auto-submit[bot] merged 5 commits intoOct 22, 2026
Conversation
…n support to tool extension protocol Adds bidirectional JSON-RPC 2.0 notification support (, , and ), sliding inactivity timeout monitoring with progress/heartbeat resets (), and cooperative request cancellation ( and ). Updates to use instead of an unbounded . Part of flutter#190755 Part of flutter#190746 Fixes flutter#193955
This was referenced Oct 21, 2026
Merged
… and post-handshake isolate exit handling Simplifies the extension protocol changes to focus on bidirectional JSON-RPC 2.0 notification support and resilient post-handshake isolate exit and error handling, removing request cancellation and heartbeat APIs. Part of flutter#190755 Part of flutter#190746
…nd isolate exit handling - Log unhandled extension isolate errors using logger.printError instead of trace so failure reasons are visible at default verbosity. - Close receive port, error port, exit port, and notification controllers on unexpected isolate exit. - Validate onNotification payload type and warn on malformed payloads rather than falling back to an empty map. - Strengthen unit test assertions on StateError messages and verify notification streams emit done on unexpected isolate exit. Part of flutter#190755 Part of flutter#190746 Fixes flutter#193955
…t listeners - Switch _errorPort and _exitPort from RawReceivePort to ReceivePort. - Add _handleIsolateError and _handleIsolateExit helper methods with documentation explaining unhandled error list payloads and unexpected exit handling. - Wire stream listeners in ExtensionConnection.spawn before isolate spawning and dispatch to active connection once created. Part of flutter#190755 Part of flutter#190746
bkonyi
marked this pull request as ready for review
October 22, 2026 15:25
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for JSON-RPC 2.0 notifications between the host tool and tool extension isolates, and improves robustness by handling unexpected isolate exits and uncaught async errors. Specifically, it adds notification sending and receiving capabilities to ToolExtensionService and ExtensionConnection, and manages isolate error and exit ports to prevent hangs. Feedback suggests refactoring _handleIsolateExit to call dispose() directly to avoid duplicating cleanup logic and ensure _isDisposed is correctly set to true, preventing potential memory leaks.
…e 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
chingjun
approved these changes
Oct 22, 2026
This was referenced Oct 23, 2026
This was referenced Oct 26, 2026
suryaKommana2662
pushed a commit
to suryaKommana2662/flutter
that referenced
this pull request
Oct 29, 2026
…isolate exit handling to ExtensionConnection (flutter#194961) Adds extension-to-host JSON-RPC notification support (`ToolExtensionService.sendNotification` and `ExtensionConnection.onNotification`, first consumed by device log streaming in flutter#194964) and keeps `onError`/`onExit` ports open after the handshake so unexpected isolate exits or unhandled errors immediately fail pending `sendRequest(..., timeout: null)` calls and close notification streams instead of hanging forever. Part of flutter#190755 Part of flutter#190746
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.
Adds extension-to-host JSON-RPC notification support (
ToolExtensionService.sendNotificationandExtensionConnection.onNotification, first consumed by device log streaming in #194964) and keepsonError/onExitports open after the handshake so unexpected isolate exits or unhandled errors immediately fail pendingsendRequest(..., timeout: null)calls and close notification streams instead of hanging forever.Part of #190755
Part of #190746