Skip to content

OpenCode background service hangs Terminal.app #51329

Open

Description

@hugo

Description

After running opencode, the service that is started prevents Terminal.app quitting cleanly. This is a problem on recent macOS which will report to you that the service is a leaked background process. It may well be deliberate and intentional that the service is spawned in the background, but it's not done in a way that the OS thinks is kosher.

Image

Plugins

No response

OpenCode version

v2

Steps to reproduce

Launch Terminal.app
Run opencode e.g. opencode run "say hi"
Exit Terminal.app
Observe that the OS reports a background process and leaves Terminal.app in the Dock.

Screenshot and/or share link

Screen.Recording.2026-09-25.at.12.05.24.pm.mov

Operating System

macOS 27

Terminal

Terminal.app

Activity

  1. changed the title [-]OpenCode background service hangs Terminal.ap[/-] [+]OpenCode background service hangs Terminal.app[/+] on Sep 25, 2026
  2. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    This issue might be related to existing reports about background-service lifecycle and process cleanup. Please check:

    • #50633: the Desktop background opencode-cli service remains running after the app closes; the report requests clean shutdown (Windows).
    • #45938: reports macOS process-cleanup/orphan behavior on exit, though the observed symptom differs.
  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and the video! In v2, opencode starts a shared background service on purpose, and it keeps running after the command ends. What you're seeing is how macOS reacts to that service: Terminal.app can't quit cleanly and macOS reports a leaked background process. That only happens on macOS with Terminal.app, and our automated sandbox runs Linux, so it couldn't reproduce this. A maintainer with a Mac will need to look at it.

    In the meantime, you can try turning off the background service (available since v2.1.4):

    opencode service set disabled true

    Each CLI call then runs its own private server and doesn't leave a service behind. To go back, run opencode service unset disabled. It would help if you could say whether Terminal.app quits cleanly with this setting, and which exact version opencode --version prints.

    Related: #50633, where the Desktop app's background service keeps running after the app closes. A commenter there sees "Running in Background" on macOS 27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions