Auto-updater: parallel server processes race bun install on the same pending version (TOCTOU)
Author: JoJohanseCreated Sep 23, 2026Updated Sep 23, 2026
Follow-up from #1278 — the windowsHide fix removes the user-visible symptom; this tracks the wasted-work amplifier behind it.
Mechanism
hasChecked(src/hooks/auto-update-checker/index.ts) dedups only within a single server process.- The desktop app runs one opencode server process per project/window. When a new plugin version is pending, each process's first top-level
session.createdpasses the gate and runs its ownbun installinto staging. getCachedVersion(src/hooks/auto-update-checker/checker.ts) reads the running module's package.json, so every process still on the old version re-detects the update — including after another process already staged/published it — until each server restarts.
Observed on Windows 11 / OpenCode Desktop 2.0.14: 5 parallel Update available checks within the same second (5 open project windows), followed by further reinstall rounds after a successful publish, from servers still on the old version.
Harm
- Redundant npm traffic and staging churn, multiplied by open windows
- Cross-window version flapping until all servers restart
- Each install is a real CPU/network cost even when the console window is hidden
Suggested directions
- Cross-process install lock (precedent:
acquirePidFileLockWithRetryinsrc/companion/manager.ts) - After acquiring the lock, re-check whether the staged/published version already equals
latestVersionbefore installing
Source: alvinunreal/oh-my-opencode-slim