Skip to content

[flutter_tools] Fix unhandled DebugAdapterException on early process termination - #192294

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
bkonyi:issue-dap-session-terminated
Sep 4, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
bkonyi:issue-dap-session-terminated

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

When a target application process exits prematurely (e.g. exit code 255) before the Debug Adapter Protocol (DAP) initialization handshake completes, flutter_tools crashed with an unhandled DebugAdapterException in the Dart Zone.

In Flutter 3.47.2 telemetry, this was the #3 top crasher with 203 crashes (DebugAdapterException-34d39b25).

Root Cause

  1. FlutterBaseDebugAdapter.handleSessionTerminate completed debuggerInitializationFailedCompleter.completeError(...) before calling super.handleSessionTerminate(...).
  2. In package:dap_adapters (DartDebugAdapter), handleSessionTerminate is asynchronous and awaits pending output events before setting isTerminating = true.
  3. In FlutterDebugAdapter._handleAppStarted, the unawaited asynchronous message handler caught the error while isTerminating was still false, rethrowing DebugAdapterException into the Zone.

Fix

  1. Synchronously set isTerminating = true in FlutterBaseDebugAdapter.handleSessionTerminate.
  2. In FlutterDebugAdapter._handleAppStarted, catch DebugAdapterException and send the message to console output rather than rethrowing into the Zone.
  3. Clean up early termination message formatting when exitSuffix is provided.

Related Issues

  • Fixes crasher DebugAdapterException-34d39b25 in Flutter 3.47.1 and 3.47.2 telemetry.

Tests

  • Added regression tests in packages/flutter_tools/test/general.shard/dap/flutter_adapter_test.dart and flutter_test_adapter_test.dart verifying that early process exit outputs cleanly to console and does not produce unhandled asynchronous exceptions.

…termination

When a target process exits before debugger initialization completes,
the debug adapter previously threw an unhandled DebugAdapterException in
_handleAppStarted because isTerminating was not yet true when the
debuggerInitializationFailedCompleter error was handled.

This change:
1. Sets isTerminating to true immediately in FlutterBaseDebugAdapter.handleSessionTerminate.
2. Catches DebugAdapterException in FlutterDebugAdapter._handleAppStarted, outputting the error message to the console and cleanly returning without rethrowing.
3. Formats the early termination message cleanly when exitSuffix is provided.
4. Adds regression tests verifying early process exit does not produce unhandled exceptions in launch and attach modes.
@bkonyi bkonyi added the CICD Run CI/CD label Sep 4, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 4, 2026
@bkonyi
bkonyi requested a review from DanTup September 4, 2026 15:37
@bkonyi
bkonyi marked this pull request as ready for review September 4, 2026 15:37

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Flutter debug adapters to handle cases where the process terminates before the debugger is initialized, preventing unhandled exceptions. It catches DebugAdapterException to output the error message to the console and adds corresponding tests. The review feedback notes that catching all other exceptions on Object and printing them to the console when isTerminating is false silently swallows unexpected errors, and suggests preserving the original rethrow behavior for non-DebugAdapterException exceptions.

Comment on lines +472 to 476
} on Object catch (e) {
if (!isTerminating) {
rethrow;
sendConsoleOutput('Failed to initialize debugger: $e');
}
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The PR description states that the goal is to catch DebugAdapterException and send it to console output rather than rethrowing. However, the current implementation also changes the behavior for other unexpected exceptions (caught via on Object catch (e)) when isTerminating is false, by printing them to the console and returning instead of rethrowing them.

To ensure unexpected programming errors or other critical failures are still reported and not silently swallowed, we should preserve the original rethrow behavior for non-DebugAdapterException exceptions when isTerminating is false.

Suggested change
} on Object catch (e) {
if (!isTerminating) {
rethrow;
sendConsoleOutput('Failed to initialize debugger: $e');
}
return;
} on Object catch (e) {
if (!isTerminating) {
rethrow;
}
return;

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 4, 2026
Merged via the queue into flutter:master with commit b570999 Sep 4, 2026
30 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 4, 2026
…12760)

Manual roll Flutter from 70797e15325e to 5a6cfa7f3d26 (52 revisions)

Manual roll requested by [email protected]

flutter/flutter@70797e1...5a6cfa7

2026-09-04 [email protected] [tool] Migrate ScreenshotCommand to modular dependency injection (flutter/flutter#190767)
2026-09-04 [email protected] Roll Skia from 8fce167bdded to 93ac1e630d1d (3 revisions) (flutter/flutter#192306)
2026-09-04 [email protected] Add iOS Universal Link integration test (Simulator) (flutter/flutter#191443)
2026-09-04 [email protected] [AGP 9.1.0 Migration #5] Delete getLegacyAndroidExtension and migrate NDK fallback to public DSL (flutter/flutter#192116)
2026-09-04 [email protected] Reland "[tool_tests] Remove bringup from Windows tool_tests_commands_2_2" (#191732) (flutter/flutter#191802)
2026-09-04 [email protected] [flutter_tools] Fix unhandled DebugAdapterException on early process termination (flutter/flutter#192294)
2026-09-04 [email protected] Roll Packages from f9b3954 to 9af9c60 (4 revisions) (flutter/flutter#192292)
2026-09-04 [email protected] Roll Skia from 2e3f7e07eee6 to 8fce167bdded (5 revisions) (flutter/flutter#192283)
2026-09-04 [email protected] Roll Fuchsia Linux SDK from GTZNkoIR_WegRPWgL... to FgDQeF6jb1dVRVh3K... (flutter/flutter#192276)
2026-09-04 [email protected] Roll Skia from b6b00df360e5 to 2e3f7e07eee6 (2 revisions) (flutter/flutter#192275)
2026-09-04 [email protected] [iOS] TextField should support typing accented words with external keyboard (flutter/flutter#191062)
2026-09-04 [email protected] Roll Skia from 1f68c0b16f17 to b6b00df360e5 (7 revisions) (flutter/flutter#192269)
2026-09-04 [email protected] [flutter_tools] add typed enum and defaulted option descriptors (flutter/flutter#191760)
2026-09-04 [email protected] Roll Dart SDK from c2edc382a4f8 to 5501d02b583d (1 revision) (flutter/flutter#192263)
2026-09-04 [email protected] [Linux] Use fences to synchronize frames between OpenGL contexts (flutter/flutter#192098)
2026-09-03 [email protected] Defer semantics geometry updates for blocked branches (flutter/flutter#192146)
2026-09-03 [email protected] Roll Skia from 8d3e197531c6 to 1f68c0b16f17 (8 revisions) (flutter/flutter#192244)
2026-09-03 [email protected] Fix DeleteSurrounding splitting UTF-16 surrogate pairs (flutter/flutter#190514)
2026-09-03 [email protected] Remove no-shuffle from progress indicator test (flutter/flutter#186655)
2026-09-03 [email protected] [material] Remove unused parameters from constructors of generic test class (flutter/flutter#191764)
2026-09-03 [email protected] Handle linear and radial gradients in UberSDF (re-implement after fix) (flutter/flutter#192124)
2026-09-03 [email protected] Roll Dart SDK from fcbfb64f42a1 to c2edc382a4f8 (2 revisions) (flutter/flutter#192240)
2026-09-03 [email protected] Fix parsing of --enable-hcpp-and-surface-control switch and add --no-enable-hcpp tests (flutter/flutter#192202)
2026-09-03 [email protected] Fix issue where shapes rendered with gradient+blur+rotation end up incorrectly cut off (flutter/flutter#192136)
2026-09-03 [email protected] Fix sibling nodes crash under MergeSemantics (flutter/flutter#191587)
2026-09-03 [email protected] Makes backdrop groups operate on the union. (flutter/flutter#191838)
2026-09-03 [email protected] Roll Skia from 008936396810 to 8d3e197531c6 (1 revision) (flutter/flutter#192236)
2026-09-03 [email protected] [docs] Remove superseded AI rules for Flutter (flutter/flutter#192185)
2026-09-03 [email protected] Collect analytics about SwiftPM errors and warnings (flutter/flutter#191746)
2026-09-03 [email protected] Roll Packages from 18fe786 to f9b3954 (7 revisions) (flutter/flutter#192235)
2026-09-03 [email protected] [Linux] Remove frame sharing between OpenGL contexts (flutter/flutter#192150)
2026-09-03 [email protected] Roll Dart SDK from cf79067a1e44 to fcbfb64f42a1 (1 revision) (flutter/flutter#192228)
2026-09-03 [email protected] Roll Skia from 731fe9af4c0b to 008936396810 (3 revisions) (flutter/flutter#192225)
2026-09-03 [email protected] Roll Dart SDK from 700ab60bfe53 to cf79067a1e44 (2 revisions) (flutter/flutter#192219)
2026-09-03 [email protected] Roll Skia from 823f82e18177 to 731fe9af4c0b (5 revisions) (flutter/flutter#192217)
2026-09-03 [email protected] Fixes OverlayPortal semantics bounds corruption (flutter/flutter#192139)
2026-09-03 [email protected] Roll Fuchsia Linux SDK from idslm9FikVLy2K_A-... to GTZNkoIR_WegRPWgL... (flutter/flutter#192215)
2026-09-03 [email protected] Roll Fuchsia Test Scripts from u_fSMsPU22VvUsvSo... to VObjlh3xw2P9sEbC_... (flutter/flutter#192212)
2026-09-03 [email protected] Roll Skia from ae22da2e8308 to 823f82e18177 (13 revisions) (flutter/flutter#192209)
2026-09-02 [email protected] Expose skipTraversal in FocusableActionDetector (flutter/flutter#191308)
2026-09-02 [email protected] Add `IsProgram` mock method to `MockGLESImpl`, use it in `BufferBindingsGLESTest` (flutter/flutter#192196)
2026-09-02 [email protected] Fix nested scroll view fling crash (flutter/flutter#191130)
2026-09-02 [email protected] Fix TabBarView/PageView edge auto-scroll during mouse text selection (flutter/flutter#189544)
2026-09-02 [email protected] Bypass gamma correction when alpha >= 1.0 (flutter/flutter#192193)
...
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…lutter#12760)

Manual roll Flutter from 70797e15325e to 5a6cfa7f3d26 (52 revisions)

Manual roll requested by [email protected]

flutter/flutter@70797e1...5a6cfa7

2026-09-04 [email protected] [tool] Migrate ScreenshotCommand to modular dependency injection (flutter/flutter#190767)
2026-09-04 [email protected] Roll Skia from 8fce167bdded to 93ac1e630d1d (3 revisions) (flutter/flutter#192306)
2026-09-04 [email protected] Add iOS Universal Link integration test (Simulator) (flutter/flutter#191443)
2026-09-04 [email protected] [AGP 9.1.0 Migration flutter#5] Delete getLegacyAndroidExtension and migrate NDK fallback to public DSL (flutter/flutter#192116)
2026-09-04 [email protected] Reland "[tool_tests] Remove bringup from Windows tool_tests_commands_2_2" (#191732) (flutter/flutter#191802)
2026-09-04 [email protected] [flutter_tools] Fix unhandled DebugAdapterException on early process termination (flutter/flutter#192294)
2026-09-04 [email protected] Roll Packages from f9b3954 to 9af9c60 (4 revisions) (flutter/flutter#192292)
2026-09-04 [email protected] Roll Skia from 2e3f7e07eee6 to 8fce167bdded (5 revisions) (flutter/flutter#192283)
2026-09-04 [email protected] Roll Fuchsia Linux SDK from GTZNkoIR_WegRPWgL... to FgDQeF6jb1dVRVh3K... (flutter/flutter#192276)
2026-09-04 [email protected] Roll Skia from b6b00df360e5 to 2e3f7e07eee6 (2 revisions) (flutter/flutter#192275)
2026-09-04 [email protected] [iOS] TextField should support typing accented words with external keyboard (flutter/flutter#191062)
2026-09-04 [email protected] Roll Skia from 1f68c0b16f17 to b6b00df360e5 (7 revisions) (flutter/flutter#192269)
2026-09-04 [email protected] [flutter_tools] add typed enum and defaulted option descriptors (flutter/flutter#191760)
2026-09-04 [email protected] Roll Dart SDK from c2edc382a4f8 to 5501d02b583d (1 revision) (flutter/flutter#192263)
2026-09-04 [email protected] [Linux] Use fences to synchronize frames between OpenGL contexts (flutter/flutter#192098)
2026-09-03 [email protected] Defer semantics geometry updates for blocked branches (flutter/flutter#192146)
2026-09-03 [email protected] Roll Skia from 8d3e197531c6 to 1f68c0b16f17 (8 revisions) (flutter/flutter#192244)
2026-09-03 [email protected] Fix DeleteSurrounding splitting UTF-16 surrogate pairs (flutter/flutter#190514)
2026-09-03 [email protected] Remove no-shuffle from progress indicator test (flutter/flutter#186655)
2026-09-03 [email protected] [material] Remove unused parameters from constructors of generic test class (flutter/flutter#191764)
2026-09-03 [email protected] Handle linear and radial gradients in UberSDF (re-implement after fix) (flutter/flutter#192124)
2026-09-03 [email protected] Roll Dart SDK from fcbfb64f42a1 to c2edc382a4f8 (2 revisions) (flutter/flutter#192240)
2026-09-03 [email protected] Fix parsing of --enable-hcpp-and-surface-control switch and add --no-enable-hcpp tests (flutter/flutter#192202)
2026-09-03 [email protected] Fix issue where shapes rendered with gradient+blur+rotation end up incorrectly cut off (flutter/flutter#192136)
2026-09-03 [email protected] Fix sibling nodes crash under MergeSemantics (flutter/flutter#191587)
2026-09-03 [email protected] Makes backdrop groups operate on the union. (flutter/flutter#191838)
2026-09-03 [email protected] Roll Skia from 008936396810 to 8d3e197531c6 (1 revision) (flutter/flutter#192236)
2026-09-03 [email protected] [docs] Remove superseded AI rules for Flutter (flutter/flutter#192185)
2026-09-03 [email protected] Collect analytics about SwiftPM errors and warnings (flutter/flutter#191746)
2026-09-03 [email protected] Roll Packages from 18fe786 to f9b3954 (7 revisions) (flutter/flutter#192235)
2026-09-03 [email protected] [Linux] Remove frame sharing between OpenGL contexts (flutter/flutter#192150)
2026-09-03 [email protected] Roll Dart SDK from cf79067a1e44 to fcbfb64f42a1 (1 revision) (flutter/flutter#192228)
2026-09-03 [email protected] Roll Skia from 731fe9af4c0b to 008936396810 (3 revisions) (flutter/flutter#192225)
2026-09-03 [email protected] Roll Dart SDK from 700ab60bfe53 to cf79067a1e44 (2 revisions) (flutter/flutter#192219)
2026-09-03 [email protected] Roll Skia from 823f82e18177 to 731fe9af4c0b (5 revisions) (flutter/flutter#192217)
2026-09-03 [email protected] Fixes OverlayPortal semantics bounds corruption (flutter/flutter#192139)
2026-09-03 [email protected] Roll Fuchsia Linux SDK from idslm9FikVLy2K_A-... to GTZNkoIR_WegRPWgL... (flutter/flutter#192215)
2026-09-03 [email protected] Roll Fuchsia Test Scripts from u_fSMsPU22VvUsvSo... to VObjlh3xw2P9sEbC_... (flutter/flutter#192212)
2026-09-03 [email protected] Roll Skia from ae22da2e8308 to 823f82e18177 (13 revisions) (flutter/flutter#192209)
2026-09-02 [email protected] Expose skipTraversal in FocusableActionDetector (flutter/flutter#191308)
2026-09-02 [email protected] Add `IsProgram` mock method to `MockGLESImpl`, use it in `BufferBindingsGLESTest` (flutter/flutter#192196)
2026-09-02 [email protected] Fix nested scroll view fling crash (flutter/flutter#191130)
2026-09-02 [email protected] Fix TabBarView/PageView edge auto-scroll during mouse text selection (flutter/flutter#189544)
2026-09-02 [email protected] Bypass gamma correction when alpha >= 1.0 (flutter/flutter#192193)
...
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…lutter#12760)

Manual roll Flutter from 70797e15325e to 5a6cfa7f3d26 (52 revisions)

Manual roll requested by [email protected]

flutter/flutter@70797e1...5a6cfa7

2026-09-04 [email protected] [tool] Migrate ScreenshotCommand to modular dependency injection (flutter/flutter#190767)
2026-09-04 [email protected] Roll Skia from 8fce167bdded to 93ac1e630d1d (3 revisions) (flutter/flutter#192306)
2026-09-04 [email protected] Add iOS Universal Link integration test (Simulator) (flutter/flutter#191443)
2026-09-04 [email protected] [AGP 9.1.0 Migration flutter#5] Delete getLegacyAndroidExtension and migrate NDK fallback to public DSL (flutter/flutter#192116)
2026-09-04 [email protected] Reland "[tool_tests] Remove bringup from Windows tool_tests_commands_2_2" (#191732) (flutter/flutter#191802)
2026-09-04 [email protected] [flutter_tools] Fix unhandled DebugAdapterException on early process termination (flutter/flutter#192294)
2026-09-04 [email protected] Roll Packages from f9b3954 to 9af9c60 (4 revisions) (flutter/flutter#192292)
2026-09-04 [email protected] Roll Skia from 2e3f7e07eee6 to 8fce167bdded (5 revisions) (flutter/flutter#192283)
2026-09-04 [email protected] Roll Fuchsia Linux SDK from GTZNkoIR_WegRPWgL... to FgDQeF6jb1dVRVh3K... (flutter/flutter#192276)
2026-09-04 [email protected] Roll Skia from b6b00df360e5 to 2e3f7e07eee6 (2 revisions) (flutter/flutter#192275)
2026-09-04 [email protected] [iOS] TextField should support typing accented words with external keyboard (flutter/flutter#191062)
2026-09-04 [email protected] Roll Skia from 1f68c0b16f17 to b6b00df360e5 (7 revisions) (flutter/flutter#192269)
2026-09-04 [email protected] [flutter_tools] add typed enum and defaulted option descriptors (flutter/flutter#191760)
2026-09-04 [email protected] Roll Dart SDK from c2edc382a4f8 to 5501d02b583d (1 revision) (flutter/flutter#192263)
2026-09-04 [email protected] [Linux] Use fences to synchronize frames between OpenGL contexts (flutter/flutter#192098)
2026-09-03 [email protected] Defer semantics geometry updates for blocked branches (flutter/flutter#192146)
2026-09-03 [email protected] Roll Skia from 8d3e197531c6 to 1f68c0b16f17 (8 revisions) (flutter/flutter#192244)
2026-09-03 [email protected] Fix DeleteSurrounding splitting UTF-16 surrogate pairs (flutter/flutter#190514)
2026-09-03 [email protected] Remove no-shuffle from progress indicator test (flutter/flutter#186655)
2026-09-03 [email protected] [material] Remove unused parameters from constructors of generic test class (flutter/flutter#191764)
2026-09-03 [email protected] Handle linear and radial gradients in UberSDF (re-implement after fix) (flutter/flutter#192124)
2026-09-03 [email protected] Roll Dart SDK from fcbfb64f42a1 to c2edc382a4f8 (2 revisions) (flutter/flutter#192240)
2026-09-03 [email protected] Fix parsing of --enable-hcpp-and-surface-control switch and add --no-enable-hcpp tests (flutter/flutter#192202)
2026-09-03 [email protected] Fix issue where shapes rendered with gradient+blur+rotation end up incorrectly cut off (flutter/flutter#192136)
2026-09-03 [email protected] Fix sibling nodes crash under MergeSemantics (flutter/flutter#191587)
2026-09-03 [email protected] Makes backdrop groups operate on the union. (flutter/flutter#191838)
2026-09-03 [email protected] Roll Skia from 008936396810 to 8d3e197531c6 (1 revision) (flutter/flutter#192236)
2026-09-03 [email protected] [docs] Remove superseded AI rules for Flutter (flutter/flutter#192185)
2026-09-03 [email protected] Collect analytics about SwiftPM errors and warnings (flutter/flutter#191746)
2026-09-03 [email protected] Roll Packages from 18fe786 to f9b3954 (7 revisions) (flutter/flutter#192235)
2026-09-03 [email protected] [Linux] Remove frame sharing between OpenGL contexts (flutter/flutter#192150)
2026-09-03 [email protected] Roll Dart SDK from cf79067a1e44 to fcbfb64f42a1 (1 revision) (flutter/flutter#192228)
2026-09-03 [email protected] Roll Skia from 731fe9af4c0b to 008936396810 (3 revisions) (flutter/flutter#192225)
2026-09-03 [email protected] Roll Dart SDK from 700ab60bfe53 to cf79067a1e44 (2 revisions) (flutter/flutter#192219)
2026-09-03 [email protected] Roll Skia from 823f82e18177 to 731fe9af4c0b (5 revisions) (flutter/flutter#192217)
2026-09-03 [email protected] Fixes OverlayPortal semantics bounds corruption (flutter/flutter#192139)
2026-09-03 [email protected] Roll Fuchsia Linux SDK from idslm9FikVLy2K_A-... to GTZNkoIR_WegRPWgL... (flutter/flutter#192215)
2026-09-03 [email protected] Roll Fuchsia Test Scripts from u_fSMsPU22VvUsvSo... to VObjlh3xw2P9sEbC_... (flutter/flutter#192212)
2026-09-03 [email protected] Roll Skia from ae22da2e8308 to 823f82e18177 (13 revisions) (flutter/flutter#192209)
2026-09-02 [email protected] Expose skipTraversal in FocusableActionDetector (flutter/flutter#191308)
2026-09-02 [email protected] Add `IsProgram` mock method to `MockGLESImpl`, use it in `BufferBindingsGLESTest` (flutter/flutter#192196)
2026-09-02 [email protected] Fix nested scroll view fling crash (flutter/flutter#191130)
2026-09-02 [email protected] Fix TabBarView/PageView edge auto-scroll during mouse text selection (flutter/flutter#189544)
2026-09-02 [email protected] Bypass gamma correction when alpha >= 1.0 (flutter/flutter#192193)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants