Skip to content

Widget preview leaks processes when terminated #173616

@DanTup

Description

@DanTup

Steps to reproduce

Not sure if this is Windows specific.

  • Create or cd to a sample Flutter project
  • Run flutter widget-preview start --web-server
  • Wait for "Done loading previews" to appear
  • Press Ctrl+C to terminate the process
  • Repeat some number of times

Here's a PowerShell script that does this in a loop 10 times:

for ($i = 1; $i -le 10; $i++) {
    $tempLog = Join-Path -Path $env:TEMP -ChildPath "flut_$i.txt"
    # Removed RedirectStandardError and the delay between processes
    $p = Start-Process -FilePath "flutter" -ArgumentList "widget-preview", "start", "--web-server" -PassThru -NoNewWindow -RedirectStandardOutput $tempLog
    $start = Get-Date
    while (-not ((Get-Content $tempLog -Raw -ErrorAction SilentlyContinue) -match "Done loading previews") -and ((Get-Date) - $start).TotalSeconds -lt 300) {
        Start-Sleep -Milliseconds 500
    }
    Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue
}

cc @bkonyi

Expected results

No dart processes should be left running in the background.

Actual results

Lots of dart, dartaotruntime and dartvm processes are left running (some of these are DevTools and DTD).

Code sample

N/A

Screenshots or Video

Image

Logs

No useful output is collected (even in with -v) when pressing Ctrl+C:

[        ] <- accept
[        ] Caching compiled dill
[  +23 ms] lib\main.dart is being served at http://localhost:53696
[        ] The web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved
development
           workflow.
[   +2 ms] Done loading previews.
^CTerminate batch job (Y/N)? y
PS D:\Dev\Test Projects\flutter_counter>

Flutter Doctor output

Doctor output
[!] Flutter (Channel master, 3.33.0-1.0.pre-1343, on Microsoft Windows [Version 10.0.26100.4652], locale en-GB) [3.4s]
    • Flutter version 3.33.0-1.0.pre-1343 on channel master at D:\Dev\Google\Flutter\Flutter main
    ! Warning: `dart` on your path resolves to D:\Tools\Dart\Stable\bin\dart.exe, which is not inside your current Flutter SDK checkout at
      D:\Dev\Google\Flutter\Flutter main. Consider adding D:\Dev\Google\Flutter\Flutter main\bin to the front of your path.
    ! Upstream repository git@github.com:DanTup/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to git@github.com:DanTup/flutter.git to dismiss this error.
    • Framework revision 1590543f67 (3 days ago), 2025-08-08 23:18:19 -0400
    • Engine revision d77a9629f2
    • Dart version 3.10.0 (build 3.10.0-81.0.dev)
    • DevTools version 2.49.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-native-assets, enable-lldb-debugging
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Windows Version (11 Pro 64-bit, 24H2, 2009) [816ms]

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,974ms]
    • Android SDK at C:\Users\danny\AppData\Local\Android\sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Chrome - develop for the web [56ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5) [55ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.10.35122.118
    • Windows 10 SDK version 10.0.26100.0

[✓] Connected device (3 available) [97ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.4652]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 139.0.7258.66
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 138.0.3351.77

[✓] Network resources [510ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: widget previewsIssues related to the Widget Previewer toolingteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions