Skip to content

fix(server): clean up Windows machine discovery process trees - #115

Draft
wenyue wants to merge 2 commits into
Arenukvern:mainfrom
wenyue:codex/windows-machine-discovery-cleanup
Draft

fix(server): clean up Windows machine discovery process trees#115
wenyue wants to merge 2 commits into
Arenukvern:mainfrom
wenyue:codex/windows-machine-discovery-cleanup

Conversation

@wenyue

@wenyue wenyue commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • coalesce identical overlapping flutter attach --machine discovery requests and serialize requests with different inputs
  • on Windows, validate the shell wrapper by PID, creation time, executable name, and command line before terminating it through a retained native process handle
  • retain descendant identity as PID plus creation time, stop the verified wrapper, then repeatedly rescan and terminate matching Dart descendants until the tree is stably empty
  • fail closed on PowerShell/runtime errors; remove the unsafe bare-PID taskkill and direct-kill fallbacks
  • preserve the public const FlutterToolMachineDiscovery(...) constructor

Root cause

FlutterToolMachineDiscovery starts Flutter with runInShell: true, so Windows returns a cmd.exe wrapper. Live process tracing showed that taskkill /PID <cmd-pid> /T /F terminated the wrapper but left the dart.exe and dartvm.exe processes running. Repeated discovery therefore accumulated orphaned flutter_tools.snapshot attach --machine processes and memory.

The hardened cleanup snapshots and verifies the exact wrapper identity, pins its native process handle, records descendant identities as PID plus CreationDate, stops the wrapper, and rescans for late-created descendants. The root tombstone is bounded by the verified handle's ExitTime, preventing PID reuse from extending the old tree.

Validation

  • Flutter 3.44.8 analyze on the changed source and tests: no issues
  • Flutter 3.44.8 focused tests: 17 passed
  • steward probe --json --profile quick: all 8 actions passed
  • git diff --cached --check
  • GitNexus staged impact: medium, limited to four existing machine-discovery flows
  • compiled Windows executable and copied it into the local cache with matching SHA-256
  • real cached-binary lifecycle smoke: observed 2 attach descendants, cleanup completed in 4453 ms, 0 remaining
  • independent staged-diff review: Ready to merge, no remaining Critical or Important findings
  • full make check-contracts was not run; the repository-owned quick gate and focused Dart checks above passed

Contributor Checklist

  • User-facing change recorded under CHANGELOG.md Unreleased
  • No secrets, tokens, or private URLs added
  • Existing unrelated worktree changes were not staged or modified

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5dd3b26c-edb7-49d1-8f41-2bdf4277e805

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant