Skip to content

fix(core): clean up idle instances and stale subprocess state#21573

Open
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:fix/instance-lifecycle-cleanup
Open

fix(core): clean up idle instances and stale subprocess state#21573
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:fix/instance-lifecycle-cleanup

Conversation

@sjawhar
Copy link
Copy Markdown

@sjawhar sjawhar commented Apr 8, 2026

Issue for this PR

Closes #21570

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This hardens shared serve-mode instance cleanup so idle per-directory state does not linger longer than necessary.

It adds instance activity tracking and idle disposal, improves stale subprocess cleanup in the bash/process path, clears empty RPC/listener state, and makes related cleanup paths explicit in bootstrap, shutdown, and background resource handling.

How did you verify your code works?

  • cd packages/opencode && bun typecheck
  • cd packages/opencode && bun test test/project/bootstrap.test.ts test/util/process.test.ts
  • Verified no LSP diagnostics in the main cleanup files (project/instance.ts, tool/bash.ts, index.ts)

Screenshots / recordings

N/A (core/server cleanup change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@sjawhar sjawhar force-pushed the fix/instance-lifecycle-cleanup branch from 3eefeb9 to 5ab06bf Compare April 9, 2026 18:25
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.

Serve mode can retain idle instances and stale subprocess state

1 participant