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
- Run
flutter widget-preview start in a project.
- Ensure that the Dart Tooling Daemon (DTD) is either not running, unreachable, or fails to respond to the initial
getFlutterWidgetPreviews call.
- The tool crashes with an unhandled
RpcException or StateError bubble-up, showing a full stack trace.
Scenario B: DTD connection loss during active session
- Run
flutter widget-preview start and ensure it starts successfully.
- While the tool is running and actively watching files, simulate a DTD connection loss (e.g., by terminating the DTD process).
- 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.
Summary
The
flutter widget-preview startcommand and its associated file-watching stream crash with unhandled exceptions (RpcExceptionorStateError) 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
flutter widget-preview startin a project.getFlutterWidgetPreviewscall.RpcExceptionorStateErrorbubble-up, showing a full stack trace.Scenario B: DTD connection loss during active session
flutter widget-preview startand ensure it starts successfully.StateErrororExceptionwhen attempting to communicate with DTD, terminating thewidget-previewsession abruptly.Expected Behavior
throwToolExitwith a user-friendly message indicating that DTD is unreachable or the analysis server is not running, rather than crashing with a stack trace.widget-previewis 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.