Repository navigation
Conversation
When opencode is used in a workspace containing large non-code files (media, datasets, ML models, etc.), the `git add .` in the snapshot system can run indefinitely — consuming excessive CPU and memory. This adds a 15-second timeout to `git add .`. If it times out, the snapshot system generates an exclude file that: - Skips known binary/large file extensions (.mp4, .zip, .onnx, etc.) - Copies the project's .gitignore rules - Scans top-level directories and excludes any over 100MB The retry `git add .` then runs with these exclusions in place. Normal-sized projects see zero overhead since the timeout is never hit. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #18072
Fixes #8887
Fixes #3182
Type of change
What does this PR do?
The snapshot system runs
git add .on the full worktree at every agentic step. When the worktree contains large non-code files (media, datasets, ML models, Go/npm dependencies), this operation runs indefinitely — observed running for 3+ hours at 90% CPU, with the hourlygit gccleanup consuming 3.7GB RAM. See also #3182 (98GB snapshots from Go deps) and #8887 (snapshot ignoreswatcher.ignore).This fix wraps the
git add .call in a 15-secondEffect.timeout. If it times out:git addprocess (handled by Effect's scoped interruption)info/excludefile for the snapshot repo containing:.gitignorerulesgit add .with the exclusions in placeThe exclude generation is guarded by a flag so it runs at most once per session. Normal-sized code projects see zero overhead since the timeout is never hit.
This is complementary to the
watcher.ignoreapproach proposed in #8887 — this provides a runtime safety net for users who haven't configured ignore rules.How did you verify your code works?
Tested on a workspace containing a ~500MB media directory that previously caused the snapshot system to hang. After the fix, the first
git add .times out at 15s, excludes are generated, and the retry completes quickly. Subsequenttrack()/patch()/diff()calls work normally.Checklist