Skip to content

Serve mode can retain idle instances and stale subprocess state #21570

@sjawhar

Description

@sjawhar

Description

Shared opencode serve instances can keep stale per-directory resources alive longer than intended: idle instances, subprocess handles, RPC/listener state, and related background cleanup work are not aggressively reclaimed. This shows up as long-lived server state even after the relevant worktree/session is no longer active.

The hardening work here adds explicit instance activity tracking, idle disposal, stale bash process reaping, and listener/cache cleanup so per-directory instances can shut down cleanly instead of accumulating background state.

Plugins

No response

OpenCode version

0.0.0--202604082056 (local built binary / dev branch work)

Steps to reproduce

  1. Start opencode serve against a project.
  2. Create activity that opens per-directory instances and starts subprocess-backed work (bash/task/LSP/session flows).
  3. Leave the server idle or switch away from the active worktree/directory.
  4. Observe that process/listener cleanup is incomplete and state can linger longer than expected.

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04

Terminal

Ghostty

Metadata

Metadata

Assignees

No one assigned

    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