Repository navigation
feat(server): safely evict idle directory instances - #42631
kernel-oops wants to merge 1 commit into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found one potentially related PR: Related PR:
The current PR (#42631) appears to be a more refined, safety-focused implementation with explicit opt-in through an experimental flag and comprehensive safety mechanisms, whereas #33713 seems to be a simpler fix addressing the same underlying issue. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Scope: opt-in idle eviction of directory instances: a module-level activity tracker (per-directory generation counter + running-PTY counts), PTY start/stop hooks, a 1-minute sweep that disposes instances idle beyond a configurable timeout, and refactored instance-store leasing (
|
|
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 #33720
Type of change
What does this PR do?
opencode servekeeps one runtime per directory forever, retaining its plugins, watchers, LSPs, MCPs, and database handles. This adds opt-in idle disposal throughOPENCODE_EXPERIMENTAL_INSTANCE_IDLE_TIMEOUT_MS(minimum one hour; unset means disabled).Activity leases and final busy-state checks prevent disposal during requests, session runs, background jobs, or PTYs. A disposing tombstone makes concurrent loads wait for cleanup instead of receiving a runtime that is being destroyed. Symlink aliases remain reserved while a waiter retries, preventing duplicate runtimes after retargeting.
This is deliberately timeout-based rather than entry-count LRU: an old directory may still contain active background work.
How did you verify your code works?
Added deterministic tests for request leases, concurrent disposal/load, session/background/PTY activity, symlink retargeting, interrupted waiters, and disabled/invalid timeout settings. Ran the focused Core/OpenCode tests, both typechecks, lint/format checks, and a native Linux x64 build plus binary smoke test.
Screenshots / recordings
N/A — server/runtime change only.
Checklist