[beta] CP: Fixes hot reload/restart crashes after closing browser tab on web-server device#177456
Conversation
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a crash during hot reload/restart on web-server devices when no client is connected. The introduction of specific error handling for RPCErrors and a new _handleNoClientsAvailable helper method for graceful failure is a solid approach. The refactoring improves code readability, and the addition of a new integration test ensures the fix is well-covered. Overall, these are good changes that improve the developer experience for Flutter web.
| 'instance in Chrome.\nThis can happen if the websocket connection used by the ' | ||
| 'web tooling is unable to correctly establish a connection, for example due to a firewall.'; | ||
|
|
||
| const kNoClientConnectedMessage = 'Recompile complete. No client connected.'; |
There was a problem hiding this comment.
The new public constant kNoClientConnectedMessage should have a documentation comment to explain its purpose, as per the style guide.1
| const kNoClientConnectedMessage = 'Recompile complete. No client connected.'; | |
| /// Message to show when a hot reload/restart is attempted with no clients connected. | |
| const kNoClientConnectedMessage = 'Recompile complete. No client connected.'; |
Style Guide References
Footnotes
-
All public members, including top-level constants, should have documentation comments. ↩
7c3f912
into
flutter:flutter-3.38-candidate.0
…wser tab on web-server device (flutter/flutter#177456)
Impacted Users:
Flutter web developers using the
web-serverdevice for hot reload/restart.Impact Description:
Hot reload/restart crashes when the browser tab is closed, causing “Bad state: No element” errors and breaking the DWDS connection.
Workaround:
Rerun the app.
Risk:
Low — changes only affect hot reload/restart handling when no clients are connected.
Test Coverage:
Yes — covered by automated integration tests and verified with manual testing across reload/restart scenarios.
Validation Steps:
flutter run -d web-serverYou should see a warning
WebSocketProxyService: No clients available.along withRecompile complete. No client connected.printed in the console. The app should no longer crash.Merged PR: #177026
Changes in DWDS (Parent PR): dart-lang/webdev#2699
Fixes #174791