Skip to content

[widget-preview] Command and file-watching stream crash when DTD connection is lost or fails at startup #187322

Description

@bkonyi

Summary

The flutter widget-preview start command and its associated file-watching stream crash with unhandled exceptions (RpcException or StateError) if the connection to the Dart Tooling Daemon (DTD) fails during startup or is unexpectedly closed during a session.

Steps to Reproduce

Scenario A: DTD failure at startup

  1. Run flutter widget-preview start in a project.
  2. Ensure that the Dart Tooling Daemon (DTD) is either not running, unreachable, or fails to respond to the initial getFlutterWidgetPreviews call.
  3. The tool crashes with an unhandled RpcException or StateError bubble-up, showing a full stack trace.

Scenario B: DTD connection loss during active session

  1. Run flutter widget-preview start and ensure it starts successfully.
  2. While the tool is running and actively watching files, simulate a DTD connection loss (e.g., by terminating the DTD process).
  3. The file-watching stream crashes due to an unhandled StateError or Exception when attempting to communicate with DTD, terminating the widget-preview session abruptly.

Expected Behavior

  • Startup: If DTD communication fails during startup, the tool should exit cleanly using throwToolExit with a user-friendly message indicating that DTD is unreachable or the analysis server is not running, rather than crashing with a stack trace.
  • During Session: If the DTD connection is lost while widget-preview is running, the tool should catch the connection error gracefully, log a warning to the user indicating that live updates are paused, and avoid crashing the active stream or the command.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listteam-toolOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions