Skip to content

Add diagnostic logging and 3m ToolExit timeout for web test hangs - #191004

Merged
auto-submit[bot] merged 16 commits into
flutter:masterfrom
mdebbar:vivid_corona_arcs_15h21
Oct 7, 2026
Merged

auto-submit[bot] merged 16 commits into
flutter:masterfrom
mdebbar:vivid_corona_arcs_15h21

Conversation

@mdebbar

@mdebbar mdebbar commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

When a web test suite hangs while loading in flutter test --platform chrome, FlutterWebPlatform.load() waits indefinitely until the CI job hits its global timeout, with no logs showing whether the browser froze, JS execution stalled in the test iframe, or an asset fetch got stuck.

To fail fast and make issues like the canvaskit.wasm loading hang (fixed in #190155) quick to identify:

  • Track in-flight network requests over CDP (Network.enable) in CdpNetworkTracker so we know which requests are still pending and for how long.
  • Add BrowserManager.diagnoseHang() to check WebSocket activity, probe CDP responsiveness (Runtime.evaluate), and list network requests pending for ≥5s.
  • Add a watchdog around _browserManager!.load() that logs the diagnostic report after 45 seconds and aborts with a ToolExit after 3 minutes.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 12, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 12, 2026

@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 introduces a diagnostic hang reporting mechanism for Flutter web tests, implementing watchdog timers to detect timeouts and a CdpNetworkTracker to track active network requests via the Chrome DevTools Protocol. Feedback on these changes identifies two issues: first, watchdog timers are only cancelled when the test suite finishes, which can trigger false-positive timeouts for long-running suites; second, the diagnostic logic incorrectly requires active WebSocket traffic to identify stalled asset fetches or JS execution, which prevents accurate diagnosis when the browser is hung and the WebSocket is inactive.

Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
@flutter-dashboard

Copy link
Copy Markdown

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@mdebbar

mdebbar commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 introduces watchdog timers (a 45-second warning and a 3-minute hard timeout) to diagnose and handle potential test suite timeouts or browser hangs during web test loading, along with a CdpNetworkTracker to track active network requests via the Chrome DevTools Protocol. The review feedback highlights critical issues where unhandled exceptions in the diagnostic calls could crash the test runner or prevent the timeout from completing, and suggests wrapping these calls in try-catch blocks. Additionally, the new public class CdpNetworkTracker and its members require documentation to align with the repository style guide.

Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart
@flutter-dashboard

Copy link
Copy Markdown

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #191004 at sha 4acf162

@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Sep 22, 2026
@mdebbar

mdebbar commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 introduces watchdog timers and a diagnostic hang reporter to detect and debug test suite timeouts or browser hangs in FlutterWebPlatform, utilizing a new CdpNetworkTracker to monitor active network requests. Feedback on these changes highlights a potential race condition and subscription leak in CdpNetworkTracker if dispose is called during asynchronous initialization, and recommends replacing DateTime.now with clock.now to facilitate unit testing.

Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart Outdated
@mdebbar
mdebbar requested a review from bkonyi October 6, 2026 18:07
harryterkelsen
harryterkelsen previously approved these changes Oct 6, 2026

@harryterkelsen harryterkelsen 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 with small nit

Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart
@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants