Skip to content

Conversation

@jyameo
Copy link
Contributor

@jyameo jyameo commented Oct 23, 2025

Impacted Users:
Flutter web developers using the web-server device 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:

  1. run the app on webserver flutter run -d web-server
  2. open the url
  3. do hot reload
  4. close the browser
  5. do hot reload

You should see a warning WebSocketProxyService: No clients available. along with Recompile 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

@flutter-dashboard
Copy link

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.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 23, 2025
Copy link
Contributor

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

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 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.';
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The new public constant kNoClientConnectedMessage should have a documentation comment to explain its purpose, as per the style guide.1

Suggested change
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

  1. All public members, including top-level constants, should have documentation comments.

@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp: review Cherry-picks in the review queue 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