Skip to content

Desktop: project icon discovery can block sidecar for minutes on large directory trees #29953

@oomp

Description

@oomp

Summary

OpenCode Desktop can make its local sidecar server unresponsive for many minutes when opening a git project that contains a very large directory tree. The trigger appears to be desktop-enabled project icon discovery.

In the packaged desktop app, preferAppEnv() forces:

OPENCODE_EXPERIMENTAL_ICON_DISCOVERY: "true"

Then Project.fromDirectory starts Project.discover, which runs an unbounded recursive glob over the whole worktree:

fs.glob("**/favicon.{ico,png,svg,jpg,jpeg,webp}", {
  cwd: input.worktree,
  absolute: true,
  include: "file"
})

On worktrees with a pathological number of directories, this can monopolize the sidecar process. While this is happening, even /global/health does not respond, so the Desktop app reports the local server as down. After the glob eventually finishes, the server becomes healthy again.

Environment

  • OpenCode Desktop: 1.15.12
  • OS: Windows
  • Project type: git worktree
  • Desktop local sidecar process: Electron node.mojom.NodeService

Observed behavior

  1. OpenCode Desktop starts normally and the sidecar reports ready.
  2. Opening a specific git worktree triggers directory-specific requests.
  3. The sidecar stops responding even to /global/health.
  4. One sidecar thread burns CPU for many minutes.
  5. After enough time passes, the server recovers and endpoints respond again.

This looks like a CPU-bound scan rather than a crash or permanent deadlock.

Evidence

In a real project, a runtime/cache directory contained a very large tree:

data/free-runtime/stale-leases

A safe diagnostic scan that intentionally skipped .git, .venv, venv, Backups, and editor/service directories still did not finish after 30 seconds and had already visited:

177350 directories
6865 files
0 favicon matches

Chromium request logs showed a long gap where only health/event requests were attempted; after the CPU-bound work completed, normal endpoints resumed.

The issue reproduces in Desktop, but not in CLI-like usage, which is consistent with Desktop forcing OPENCODE_EXPERIMENTAL_ICON_DISCOVERY=true.

Expected behavior

Project icon discovery should not be able to make the sidecar/local server unavailable.

At minimum, it should:

  • honor common ignore directories such as .git, node_modules, .venv, venv, dist, build, cache/runtime directories, and ideally configured watcher/gitignore excludes;
  • use a bounded search strategy rather than **/favicon... over the entire worktree;
  • have a timeout or match/entry limit;
  • not block sidecar health/API responsiveness;
  • allow users to explicitly disable desktop icon discovery via env/config instead of Desktop unconditionally forcing it on.

Suggested fixes

Possible options:

  1. Do not force OPENCODE_EXPERIMENTAL_ICON_DISCOVERY=true in Desktop when the user explicitly set it to false.
  2. Replace the full recursive glob with bounded candidate paths, for example root/public/static/assets/app directories with limited depth.
  3. Apply the same ignore/protected directory policy used elsewhere before scanning.
  4. Run icon discovery in a cancellable worker/child process with timeout/limit so it cannot block the sidecar event loop.
  5. Skip discovery once a project has any explicit icon override, and expose that as a normal UI/config fallback.

Workaround

Setting an explicit project icon override prevents Project.discover from scanning that project, but users should not need to patch local state to keep Desktop responsive.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions