[Tool] Fix widget-preview crash by waiting for analysis server#187941
Conversation
The `flutter widget-preview start` command was crashing with an `RpcException` (method not found) because it attempted to call `dart/workspace/getFlutterWidgetPreviews` immediately after the `Lsp` service was registered, but before the Analysis Server had finished its initial analysis and registered the specific method. This change: - Waits for the initial analysis to complete after initializing the LSP preview detector. - Increases the retry limit for DTD calls to the widget preview methods from 5 to 50 (with 200ms delay, increasing the total wait from 1s to 10s) to handle slower environments. - Adds a unit test to verify that the tool indeed waits for the analysis server to finish initial analysis. Fixes flutter#187367
There was a problem hiding this comment.
Code Review
This pull request updates the widget preview start command to wait for the initial analysis to complete before populating DTD connection info, and increases the maximum retry attempts for retrieving widget previews from 5 to 50. It also adds a corresponding test to verify that analysis completion is awaited. However, the retry logic in dtd_services.dart contains an infinite loop bug where caught RpcExceptions that do not meet the retry criteria are not rethrown, causing the loop to run indefinitely.
Refactored the retry logic in getFlutterWidgetPreviews and getFlutterWidgetPreviewsForFile to use a standard for-loop. This improves readability and addresses feedback regarding loop termination clarity.
|
autosubmit label was removed for flutter/flutter/187941, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
…er#187941) The `flutter widget-preview start` command was crashing with an `RpcException` (method not found) because it attempted to call `dart/workspace/getFlutterWidgetPreviews` immediately after the `Lsp` service was registered, but before the Analysis Server had finished its initial analysis and registered the specific method. This change: - Waits for the initial analysis to complete after initializing the LSP preview detector. - Increases the retry limit for DTD calls to the widget preview methods from 5 to 50 (with 200ms delay, increasing the total wait from 1s to 10s) to handle slower environments. - Adds a unit test to verify that the tool indeed waits for the analysis server to finish initial analysis. Fixes flutter#187367
…12041) Manual roll requested by [email protected] flutter/flutter@87224e0...11e339e 2026-06-23 [email protected] [flutter_tools] Migrate analysis_options.yaml to exclude build and platform directories by default (flutter/flutter#187940) 2026-06-23 [email protected] Update docs for PR limits (flutter/flutter#188388) 2026-06-23 [email protected] Roll Packages from cd5194a to 7d84a69 (4 revisions) (flutter/flutter#188383) 2026-06-23 [email protected] [Tool] Fix widget-preview crash by waiting for analysis server (flutter/flutter#187941) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
The
flutter widget-preview startcommand was crashing with anRpcException(method not found) because it attempted to calldart/workspace/getFlutterWidgetPreviewsimmediately after theLspservice was registered, but before the Analysis Server had finished its initial analysis and registered the specific method.This change:
Fixes #187367