Skip to content

Conversation

@cesaralexanderds
Copy link

@cesaralexanderds cesaralexanderds commented Jan 10, 2026

Summary
Fixes the OpenCode extension hanging indefinitely on "Loading..." when opening Git repositories in Zed editor on Windows.

Problem
When opening a Git repository in Zed on Windows, three git commands in Project.fromDirectory() would hang indefinitely:

  • git rev-list --max-parents=0 --all (project ID generation)
  • git rev-parse --show-toplevel (repository root detection)
  • git rev-parse --git-common-dir (worktree detection)
    This caused the Zed extension to freeze during initialization, preventing users from using the OpenCode assistant in any Git repository.

Root Cause
The issue was initially reported as a Zed bug in zed-industries/zed#43335, but investigation revealed it was an OpenCode bug. The git commands were executed without any timeout mechanism, causing indefinite hangs on Windows when called through the Zed Agent Communication Protocol.

Solution
Added a gitWithTimeout() helper function that wraps git command promises with a 5-second timeout using Promise.race(). When a timeout occurs:

  • Logs a warning message for debugging (log.warn)
  • Returns the fallback value (undefined)
  • Triggers existing fallback logic (already in place for when git commands fail)
  • Gracefully degrades to non-git behavior instead of hanging
    The timeout is conservative enough (5 seconds) that it won't affect normal git operations on any platform, but prevents indefinite hangs.

Testing

  • Tested on Windows 11 with Zed 0.218.6
  • Confirmed extension now loads successfully in Git repositories
  • Binary built and tested locally with the patched code
  • No impact on non-Windows platforms (timeout is generous for normal operations)
  • Fallback behavior works correctly when timeout is triggered

Related Issues

Changes

  • Added gitWithTimeout() helper function in packages/opencode/src/project/project.ts
  • Wrapped three git commands with timeout protection
  • Added warning log when timeout occurs for debugging purposes

Fixes #7587

…dows

When opening Git repositories in the Zed editor on Windows, the OpenCode
extension would hang indefinitely on "Loading..." due to git commands
blocking without timeout in Project.fromDirectory().

This adds a gitWithTimeout() helper that wraps git commands with a 5-second
timeout, allowing graceful fallback to non-git behavior instead of hanging.

The three affected git commands are:
- git rev-list --max-parents=0 --all (project ID generation)
- git rev-parse --show-toplevel (repository root detection)
- git rev-parse --git-common-dir (worktree detection)

Tested on Windows with Zed 0.218.6 and confirms the extension now loads
successfully in Git repositories.
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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.

Zed extension hangs on "Loading..." when opening Git repositories on Windows

1 participant