Skip to content

upgrade: long-running serve from previous version keeps running after auto-update (404 on /api/status, service exits) #49664

Closed

Description

@patrickzxk

Summary

After an auto-update (autoupdate: true, 2.0.5 → 2.0.7), the previously running background serve process is not stopped. The stale process keeps reconnecting to the new installation: /api/status returns 404, service registration data appears missing/overwritten, and the background service exits. Killing the stale process restores normal startup.

Environment

  • opencode version: 2.0.7 (upgraded from 2.0.5)
  • OS: macOS (Darwin 27.0.0, arm64)
  • Terminal: Ghostty, TERM=xterm-256color
  • Shell: /bin/zsh
  • Install/channel: latest (npm @opencode/cli), autoupdate: true
  • Active plugins: /Users/zhangxiaokang/Workspace/opencode2-quota

Reproduction

  1. Start opencode's background service (e.g. opencode serve) and leave it running.
  2. Keep that process alive, then install / auto-update to a newer version (here 2.0.5 → 2.0.7).
  3. Observe the previous-version serve process continuing to run and reconnect to the updated on-disk state.
  4. Use the service / open a session.

Expected Behavior

  • An upgrade should terminate or cleanly hand off the long-running serve process from the previous version, or otherwise prevent a stale process from reconnecting against the new installation.
  • The background service should stay healthy after the upgrade.

Actual Behavior

  • The old process logs repeated reconnection attempts and /api/status returns 404.
  • Service registration data appears lost / overwritten ("service registration file …", "background service exited").
  • The background service exits and opencode appears broken until the stale process is killed manually.

Additional Context

  • Frequency: occurred once, immediately after the upgrade, only while a stale previous-version serve process was still alive. Killing that process recovered startup instantly; not reproducible when only a single current-version process is running.
  • Workaround: terminate all stale opencode processes before/after upgrading, or restart the service after the upgrade.
  • Related but separate: this environment also overrides the data location via the OPENCODE_DB env var; that caused a different symptom (sessions appearing missing due to the wrong DB being opened by a non-interactive start), not the 404/registration failures described here.

Activity

  1. github-actions commented on Sep 18, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I reproduced this on 2.0.5 → 2.0.7:

    1. Start the background service with 2.0.5.
    2. Run 2.0.7. It correctly detects the old service and replaces it with a 2.0.7 one.
    3. A 2.0.5 process that is still running (for example an old TUI or client that keeps reconnecting) checks the new service at /api/status. That endpoint doesn't exist in 2.0.7, so it gets a 404. It then stops the 2.0.7 service and starts a 2.0.5 one again, overwriting the service registration.

    This restart logic is in the old 2.0.5 code, so it can only be avoided by stopping old processes after an upgrade from 2.0.5 or earlier, as you did.

    I then ran the same steps on the latest release, 2.2.0, with 2.1.4 as the leftover old version. Newer clients now reuse the running service even when its version differs, so the service was never swapped back and forth. I couldn't run the latest dev from source here, but it has the same behaviour. This looks already fixed for upgrades between current versions.

    The script below reproduces it in a temporary HOME. The bot will close this issue in 1 day unless you reply that it still happens, for example when upgrading from 2.1.x or later.

  3. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    Closing this as completed, since we haven't heard back in the last day.

    To recap: I reproduced the service swapping back and forth when upgrading from 2.0.5 to 2.0.7 while an older 2.0.5 process was still running. The health endpoint changed between those versions, so the old process saw a 404 on /api/status and restarted its own service. With the same steps on the latest release (2.2.0), the service was not replaced: newer clients reuse the running service even when its version differs. So this is most likely fixed, and the fix should also be in the next release. For upgrades from 2.0.5 or earlier, stopping old opencode processes after the upgrade avoids it.

    If it still happens for you on 2.1.x or later, please comment here or open a new issue with the versions involved and the service log. Thanks again for the detailed report!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions