Skip to content

[tool] Let the OS pick a port for chromedriver and wait for exit - #13355

Merged
auto-submit[bot] merged 9 commits into
flutter:mainfrom
mdebbar:chromedriver-port-zero
Nov 2, 2026
Merged

auto-submit[bot] merged 9 commits into
flutter:mainfrom
mdebbar:chromedriver-port-zero

Conversation

@mdebbar

@mdebbar mdebbar commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Part of flutter/flutter#194313

DriveExamplesCommand starts chromedriver --port=4444 inside the per-example loop without waiting for it to bind, and stops it with chromedriver.kill() without awaiting chromedriver.exitCode. When a package has multiple web examples (e.g. google_maps_flutter_web's example/latest and example/3-64), the dying chromedriver from the first example still holds port 4444 when the next example spawns a new chromedriver --port=4444, so the second chromedriver fails to bind and exits immediately:

Unable to start a WebDriver session for web testing.
Make sure you have the correct WebDriver server (e.g. chromedriver) running at 4444.

Example CI failures:

This PR:

  • Launches chromedriver --port=0 and waits for started successfully on port (\d+) on stdout before running flutter drive --driver-port=<port>.
  • Waits for chromedriver.exitCode after chromedriver.kill() in a finally block.

@mdebbar
mdebbar requested review from bkonyi and tarrinneal October 20, 2026 19:05
@mdebbar
mdebbar marked this pull request as ready for review October 20, 2026 19:05

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM overall.

final stdoutBuffer = StringBuffer();
final stderrBuffer = StringBuffer();
final portPattern = RegExp(r'started successfully on port (\d+)');
chromedriver.stderr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we be cancelling these subscriptions when we're done?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved the process and both subscriptions into a _ChromeDriver class whose stop() cancels them after await exitCode in 17100d3d98d. They can't be cancelled as soon as we get the port because Process.start requires draining stdout/stderr while chromedriver is still running. Output is no longer buffered once the port is known.

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

Copy link
Copy Markdown
Contributor

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 refactors DriveExamplesCommand to dynamically allocate the ChromeDriver port by starting it on port 0 and parsing the assigned port from stdout, and adds corresponding tests. Feedback indicates that the regular expression used to parse the port does not match actual ChromeDriver output, which would cause the tool to hang in production. Additionally, suggestions are made to prevent unbounded memory growth in the output buffers and to update the test mocks to use realistic ChromeDriver output.

@mdebbar mdebbar added the CICD Run CI/CD label Oct 20, 2026
@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit

auto-submit Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/packages/13355, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@mdebbar
mdebbar requested a review from bkonyi November 2, 2026 16:05
@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 2, 2026
@auto-submit
auto-submit Bot merged commit 176df83 into flutter:main Nov 2, 2026
13 checks passed
RamyAkin pushed a commit to RamyAkin/flutter that referenced this pull request Nov 3, 2026
flutter/packages@3f34a6f...1df8447

2026-11-03 [email protected] [webview_flutter] Convert iOS impl
example app to Swift (flutter/packages#13538)
2026-11-03 [email protected] [material_ui]
Temporarily exclude material_ui from non-Wasm web unit tests
(flutter/packages#13537)
2026-11-02 [email protected] [material_ui]
Removes list semantics in some a11y_assessment samples
(flutter/packages#13257)
2026-11-02 [email protected] [material_ui] Use named uniforms
instead of setFloat in InkSparkle (flutter/packages#13445)
2026-11-02 [email protected] [VPAT] Fix contrast and reflow in
three a11y_assessments demos (flutter/packages#13409)
2026-11-02 [email protected]
[two_dimensional_scrollables] Fix pinned cells hit test
(flutter/packages#13376)
2026-11-02 [email protected] [tool] Let the OS pick a port for
chromedriver and wait for exit (flutter/packages#13355)
2026-11-02 [email protected] [vector_graphics] Draw <text> under an RTL ambient
direction (flutter/packages#13408)
2026-11-02 [email protected] [VPAT] Keep a11y_assessments
snackbars open until closed (flutter/packages#13451)
2026-11-02 [email protected] [pigeon] Fix race in event channel
handler removal integration test (flutter/packages#13528)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants