Skip to content

[flutter_tools] Forcefully kill hung subprocesses 5 seconds after timeout#187178

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
bkonyi:fix-windows-process-kill
Jul 8, 2026
Merged

[flutter_tools] Forcefully kill hung subprocesses 5 seconds after timeout#187178
auto-submit[bot] merged 7 commits into
flutter:masterfrom
bkonyi:fix-windows-process-kill

Conversation

@bkonyi

@bkonyi bkonyi commented May 27, 2026

Copy link
Copy Markdown
Contributor

This PR resolves indefinite hangs inside runFlutter on Windows. In its timeout handler, after sending the graceful shutdown character q, we start a 5-second Timer that forcefully kills the process via process.kill() if it fails to exit.

Additionally, we store this backup Timer in a local variable and cancel it immediately once process.exitCode completes to prevent any resource/timer leaks in subsequent test suites.

Wrote a new integration test inside transition_test_utils_test.dart to assert and guarantee this force-kill behavior.

Fixes #186449

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 27, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 27, 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 5-second fallback timer to forcefully kill a hung process during integration tests in transition_test_utils.dart, and adds a corresponding test in transition_test_utils_test.dart to verify this behavior. The review feedback points out that the newly created Timer is not cancelled if the process exits successfully on its own, which can leak resources. It is recommended to store the timer and cancel it when the process exits.

@bkonyi
bkonyi force-pushed the fix-windows-process-kill branch from f132984 to 456eb91 Compare May 27, 2026 16:26
@github-actions github-actions Bot removed the CICD Run CI/CD label May 27, 2026
@bkonyi bkonyi changed the title Forcefully kill hung subprocesses 5 seconds after transition timeout [flutter_tools] Forcefully kill hung subprocesses 5 seconds after timeout May 27, 2026
@bkonyi bkonyi added the CICD Run CI/CD label May 27, 2026
…eout

Update the `runFlutter` test runner helper inside `transition_test_utils.dart` to forcefully terminate hung subprocesses if they fail to exit within a 5-second grace period after a transition timeout occurs and the graceful shutdown character `q` is sent to `stdin`. Additionally, we store this backup `Timer` in a local variable and cancel it immediately once `process.exitCode` completes to prevent any resource leaks in subsequent test suites. Wrote a new integration test inside `transition_test_utils_test.dart` to assert and guarantee this force-kill behavior.

Fixes flutter#186449
@bkonyi
bkonyi force-pushed the fix-windows-process-kill branch from 456eb91 to 80c17bb Compare May 27, 2026 16:43
@github-actions github-actions Bot removed the CICD Run CI/CD label May 27, 2026
@bkonyi bkonyi added the CICD Run CI/CD label May 27, 2026
@bkonyi
bkonyi changed the base branch from main to master May 27, 2026 17:23
@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels May 28, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 80c17bb6e5ce7a525f6e8bc2b6fc2a0021dfbccc, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 29, 2026
@bkonyi bkonyi added the CICD Run CI/CD label May 29, 2026
@bkonyi bkonyi added the team-tool Owned by Flutter Tool team label Jun 10, 2026
Address Dart analysis warnings and formatting issues introduced in the force-kill implementation.

- Omit obvious local variable types for `timer` in `transition_test_utils.dart` and `threwTestFailure` in `transition_test_utils_test.dart`.

- Specify type for non-obvious local variable `elapsedSeconds` in `transition_test_utils_test.dart`.

- Remove unused `dart:async` import in `transition_test_utils_test.dart`.

- Remove unnecessary `print` statement in `transition_test_utils_test.dart`.

- Increase the upper bound check for elapsed time in the test to 30 seconds to prevent flakiness on slow CI bots.

Related to flutter#187178
@github-actions github-actions Bot removed team-tool Owned by Flutter Tool team CICD Run CI/CD labels Jun 19, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 23, 2026
@bkonyi
bkonyi requested a review from chingjun June 23, 2026 17:09
chingjun
chingjun previously approved these changes Jun 29, 2026
// Start a timer to kill the process if it still hasn't exited after 5 seconds.
final timer = Timer(const Duration(seconds: 5), () {
debugPrint('${stamp()} (process still did not quit, killing forcefully)');
process.kill();

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.

process.kill() sends a SIGTERM by default. Would we want to send a SIGKILL instead?

Address review comment: use ProcessSignal.sigkill when forcefully killing the subprocess to prevent leaks and ensure it terminates properly.
@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels Jun 29, 2026
chingjun
chingjun previously approved these changes Jun 29, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 29, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 29, 2026
@auto-submit

auto-submit Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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

@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels Jun 30, 2026
bkonyi added 2 commits July 6, 2026 15:47
…est_utils

Add '-a' option to the '/usr/bin/xvfb-run' invocation. This automatically allocates a free server number, preventing virtual display conflicts and reducing flakiness when running integration tests concurrently on CI bots.
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 8, 2026
Merged via the queue into flutter:master with commit 291b830 Jul 8, 2026
162 of 163 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 10, 2026
…12169)

Manual roll Flutter from 91939cc4db78 to dc2a8703e12b (50 revisions)

Manual roll requested by [email protected]

flutter/flutter@91939cc...dc2a870

2026-07-09 [email protected] [ios,macos] Update swiftc.py flags to match swiftc (flutter/flutter#189174)
2026-07-09 [email protected] [AGP 9] Update Warn Version to AGP 9+ (flutter/flutter#189109)
2026-07-09 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#189203)
2026-07-09 [email protected] [web] Roll Chrome to 145 (framework) (flutter/flutter#182861)
2026-07-09 [email protected] Roll Packages from 52d84d6 to 20928d5 (6 revisions) (flutter/flutter#189194)
2026-07-09 [email protected] [web] Avoid absolute positioning for base CanvasKit canvas (flutter/flutter#188337)
2026-07-09 [email protected] Roll Dart SDK from cdb7217e65aa to a11fb7ed40a5 (6 revisions) (flutter/flutter#189195)
2026-07-09 [email protected] Fix dereference of nullptr in the moved-to-rect signal in the Linux embedder (flutter/flutter#189152)
2026-07-09 [email protected] Fix data for design packages (flutter/flutter#189140)
2026-07-09 [email protected] Roll Skia from 7b42d1251d54 to ab3a7b98c94d (2 revisions) (flutter/flutter#189181)
2026-07-09 [email protected] Roll Skia from 05d9d214e0b7 to 7b42d1251d54 (2 revisions) (flutter/flutter#189175)
2026-07-09 [email protected] Roll Skia from 542c8bdd7f4f to 05d9d214e0b7 (4 revisions) (flutter/flutter#189169)
2026-07-09 [email protected] UberSDF rect handling for thin (line-like) rectangles (flutter/flutter#188821)
2026-07-09 [email protected] Roll Skia from dd572c07f63c to 542c8bdd7f4f (4 revisions) (flutter/flutter#189160)
2026-07-09 [email protected] [flutter_tools] Fix hot restart for WASM web builds (flutter/flutter#187898)
2026-07-08 [email protected] Split FlViewRenderer into OpenGL and software backends (flutter/flutter#188824)
2026-07-08 [email protected] Promote android_hardware_smoke_tests out of bringup in CI (flutter/flutter#189081)
2026-07-08 [email protected] Roll Skia from 8df24be66531 to dd572c07f63c (4 revisions) (flutter/flutter#189150)
2026-07-08 [email protected] Expose LinuxWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners (flutter/flutter#188917)
2026-07-08 [email protected] Roll pub packages (flutter/flutter#189149)
2026-07-08 [email protected] fix(ci): harden some workflows (flutter/flutter#189087)
2026-07-08 [email protected] Roll Skia from 51a62da33da0 to 8df24be66531 (1 revision) (flutter/flutter#189139)
2026-07-08 [email protected] Roll Dart SDK to Dart 3.13 beta3 (flutter/flutter#189122)
2026-07-08 [email protected] [flutter_tools] Don't crash on non-UTF-8 plugin pubspec.yaml (flutter/flutter#188976)
2026-07-08 [email protected] [flutter_tools] Watch transitive #include headers for FragmentProgram hot reload (flutter/flutter#187945)
2026-07-08 [email protected] Roll Skia from 040d9f55de00 to 51a62da33da0 (1 revision) (flutter/flutter#189135)
2026-07-08 [email protected] Roll Packages from 92525f5 to 52d84d6 (7 revisions) (flutter/flutter#189134)
2026-07-08 [email protected] [flutter_tools] Forcefully kill hung subprocesses 5 seconds after timeout (flutter/flutter#187178)
2026-07-08 [email protected] Expose the app's build name and number as compile-time constants (flutter/flutter#187935)
2026-07-08 [email protected] Roll Skia from 1ff92f879815 to 040d9f55de00 (1 revision) (flutter/flutter#189131)
2026-07-08 [email protected] Roll Skia from 6137414bef5c to 1ff92f879815 (6 revisions) (flutter/flutter#189126)
2026-07-08 [email protected] [test cross imports] More test/rendering + flutter_test/test fixes (flutter/flutter#188954)
2026-07-08 [email protected] engine: explain why each candidate build was skipped in Flutter web loader (flutter/flutter#186254)
2026-07-08 [email protected] vscode: add missing unicode.h (flutter/flutter#189102)
2026-07-08 [email protected] Roll Fuchsia Linux SDK from 7RjQJBW3m-3Jl-7jr... to QcRFUtvCw2EobfJ8s... (flutter/flutter#189104)
2026-07-08 [email protected] Roll Skia from 075fbe4778d9 to 6137414bef5c (10 revisions) (flutter/flutter#189106)
2026-07-08 [email protected] engine: warn on WASM load failure when not crossOriginIsolated (flutter/flutter#186252)
2026-07-08 [email protected] Roll Dart SDK from c9bccc09e733 to db2155f56bf3 (2 revisions) (flutter/flutter#189105)
2026-07-08 [email protected] [flutter_tools] Prevent interactive device selection in machine mode (flutter/flutter#188267)
2026-07-08 [email protected] [flutter_tools] Fix wireless ADB device discovery when serial contains spaces (flutter/flutter#187943)
2026-07-07 [email protected] [web] Fix grouped autofill on iOS Chrome (flutter/flutter#187459)
2026-07-07 [email protected] Fix TextSelectionOverlay crash when layout is degenerate (flutter/flutter#188672)
2026-07-07 [email protected] [flutter_tools] Provision Android NDK in the main Gradle invocation (flutter/flutter#186337)
2026-07-07 [email protected] Android_hardware_smoke_test: Migrate to AGP 9 (flutter/flutter#189082)
...
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows tool_integration_tests_7_10 is 2.00% flaky

3 participants