Skip to content

Create Hot Restart over websocket test #173852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jyameo
Copy link
Contributor

@jyameo jyameo commented Aug 15, 2025

  • Create hot restart over websocket test
  • refactored websocket_dwds_test_common

Closes dart-lang/webdev#2669

Blocked by hot restart bug: Fix in dart-lang/webdev#2668 and #173777

  • This PR can be landed once the bug above is fixed in dwds and the dwds version is updated

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 15, 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 introduces a new integration test for hot restart over a WebSocket connection and refactors the existing hot reload test to use a new shared utility file, websocket_dwds_test_common.dart. The refactoring is well done and improves code reuse. I've identified a potential resource leak in the new common utility file where a Chrome process might not be cleaned up on certain failures. I've also pointed out a few places where documentation is missing for public members, which violates the project's style guide.

Comment on lines +23 to +24
final Duration debugUrlTimeout;
final Duration appStartTimeout;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Public fields should have documentation comments. 1

  /// The maximum time to wait for the DWDS debug URL to be available.
  final Duration debugUrlTimeout;

  /// The maximum time to wait for the app to start after Chrome connects.
  final Duration appStartTimeout;

Style Guide References

Footnotes

  1. All public members should have documentation. (link)

Comment on lines +35 to +37
final StringBuffer stdout;
final io.Process chromeProcess;
final StreamSubscription<String> subscription;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Public fields should have documentation comments. 1

  /// The captured stdout from the Flutter process.
  final StringBuffer stdout;

  /// The headless Chrome process.
  final io.Process chromeProcess;

  /// The subscription to the stdout stream of the Flutter process.
  final StreamSubscription<String> subscription;

Style Guide References

Footnotes

  1. All public members should have documentation. (link)

final StreamSubscription<String> subscription = flutter.stdout.listen((String e) {
stdout.writeln(e);
// Extract the debug connection URL
if (e.contains('Waiting for connection from Dart debug extension at http://')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have the regexp we can just use firstMatch and it'll be null if there isn't a match. It's harder to keep 2 copies of this string in sync.

r'Waiting for connection from Dart debug extension at (http://[^\s]+)',
);
final Match? match = debugUrlPattern.firstMatch(e);
if (match != null && !sawDebugUrl.isCompleted) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to see the debug URL twice? Seems like something is off if that happens so perhaps we should throw a clear error. Otherwise it'll just look like a timeout.


io.Process? chromeProcess;
try {
// Step 1: Start Flutter app with web-server device (will wait for debug connection)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment step numbers are all off by 1. I actually think the comments are unnecessary since the debugPrint is self-commenting.

subscription: subscription,
);
} catch (e) {
// Clean up on error
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this call cleanupWebSocketTestResources?

debugPrint('Step 5: Testing hot reload with WebSocket connection...');
try {
// Test hot reload functionality
debugPrint('Step 6: Testing hot reload with WebSocket connection...');
Copy link
Contributor

Choose a reason for hiding this comment

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

Having step numbers here requires keeping all these files in sync. If the common file changes then we would have to update this one too. I think for the actual testing we can omit the step numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create e2e hot restart test
3 participants