Skip to content

flutter doctor/flutter daemon hangs forever on macOS when Spotlight mdfind is unresponsive (AndroidStudioValidator has no timeout) #189177

Closed

Description

@dowork0711

Summary

On macOS, flutter doctor (and therefore flutter daemon, which runs the same
workflow validators on startup) can hang indefinitely and never return if the
system's Spotlight indexer (mdworker/mds_stores) is busy or unresponsive.

This causes IDEs (VS Code / IntelliJ Dart-Code plugin) whose "Flutter Daemon"
depends on this call succeeding within a reasonable time to fail to start.
Since the underlying process never actually exits or times out, the extension
retries forever, producing an infinite start-up loop.

Root cause

AndroidStudio.allInstalled() in
packages/flutter_tools/lib/src/android/android_studio.dart calls:

final ProcessResult spotlightResult = globals.processManager.runSync(<String>[
  'mdfind',
  'kMDItemCFBundleIdentifier="com.google.android.studio*"',
]);

This is a synchronous, blocking call with no timeout. If mdfind
doesn't return (e.g. because mds_stores/Spotlight indexing is stuck — which
can happen after macOS updates, or on large projects with heavy file churn in
build/, .dart_tool/, ios/Pods/, etc.), this call blocks the entire
flutter_tools process forever.

There is a try/catch for ProcessException right below it, but that only
guards against mdfind failing to start — not against it hanging.

Steps to reproduce

  1. Get the system into a state where Spotlight is unresponsive, e.g.:
    • mds_stores pinned at high CPU doing a long re-index (observable via
      Activity Monitor / ps aux | grep mds)
    • or simply confirm mdfind never returns:
      timeout 8 mdfind 'kMDItemCFBundleIdentifier="com.google.android.studio*"'
      exits with code 124 in this state.
  2. Run flutter doctor -v, or open a Flutter/Dart project in an IDE so it
    starts flutter daemon.
  3. Observe that flutter doctor prints only the "Flutter" section and then
    hangs forever; the Flutter Daemon in the IDE never finishes starting and
    the extension retries indefinitely.

Confirmed on this machine by sampling the hung flutter_tools.snapshot doctor -v process (sample <pid>): the thread is blocked in dart:io Process.start, and its only child process is:

/usr/bin/mdfind kMDItemCFBundleIdentifier="com.google.android.studio*"

Expected behavior

The Spotlight query is explicitly a "nice-to-have" per the existing comment
in the code. It should not be able to hang flutter doctor/flutter daemon
forever. The call should have a bounded timeout (a few seconds) and fall back
to the already-discovered candidate paths on timeout, the same way it already
falls back on ProcessException.

Environment

Flutter 3.44.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f94f4fc76b (2026-07-06)
Engine • revision 83675ed276
Tools • Dart 3.12.2 • DevTools 2.57.0
  • macOS 26.5.2 (25F84), darwin-arm64
  • mdutil -s / reports "Indexing enabled."
  • mds_stores observed pinned near 100% CPU for an extended period during
    reindexing

Suggested fix

Wrap the mdfind call with a bounded timeout (e.g. Process.start +
Future.timeout, killing the process on timeout) and treat a timeout the
same as the existing ProcessException fallback path.

Activity

  1. added
    in triagePresently being triaged by the triage team
    📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")
    toolAffects the "flutter" command-line tool. See also t: labels.
    platform-macosBuilding on or for macOS specifically
    t: flutter doctorProblem related to the "flutter doctor" tool
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-toolOwned by Flutter Tool team
    and removed
    📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")
    in triagePresently being triaged by the triage team
    on Jul 9, 2026
  2. mbcorona commented on Jul 10, 2026

    @mbcorona
    Member

    Thanks @dowork0711. Reproduced and root cause confirmed.

    I forced mdfind to hang deterministically by shadowing it with a sleep-only shim on PATH:

    mkdir -p /tmp/fakebin
    printf '#!/bin/sh\nsleep 600\n' > /tmp/fakebin/mdfind
    chmod +x /tmp/fakebin/mdfind
    export PATH=/tmp/fakebin:$PATH
    
    flutter doctor -v   # prints the Flutter section, then hangs

    sample $(pgrep -f flutter_tools.snapshot) shows it blocked in Process.start on the mdfind child, exactly as described. The runSync call in android_studio.dart has no timeout, so a stuck Spotlight takes down doctor/daemon.

    Routing to the tool team.

  3. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Jul 14, 2026
  4. self-assigned this
    on Jul 14, 2026
  5. github-actions commented on Aug 6, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-macosBuilding on or for macOS specificallyt: flutter doctorProblem related to the "flutter doctor" toolteam-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