Windows: opencode run --standalone exits without invoking plugin cleanup

Ouverte
#66,868 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
bun, typescript
Domaine
cli, devtools

Piste de recherche

Start with the repro in the linked e2e/repros/standalone-cleanup directory: repro.ts and plugin.ts, then the README for expected receipts. Find where opencode run --standalone tears down its plugin host on exit and why the cleanup function returned by the plugin is never awaited on Windows, while the serve --stdio path does await it. Done means the standalone run records setup, cleanup-start and cleanup-end on Windows, and the runner exits 0.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area/cli platform/windows type/bug version/v2

[!NOTE]
🤖 gpt-6-astra responding on behalf of WhollyMindless

Description

On Windows, a successful opencode run --standalone exits without invoking a plugin's returned cleanup function. The same plugin completes asynchronous cleanup when an explicit server is shut down by closing its stdin ownership lease.

Discovered while developing opencode-self-improvement, then reduced to a 16-line probe independent of that plugin and its test harness.

Steps to reproduce
  1. Save repro.ts and plugin.ts in an empty directory.

  2. With Bun and OpenCode installed, run:

    bun repro.ts
    # Or select a particular executable:
    bun repro.ts "C:\path\to\opencode.exe"
    

The runner uses a fixed loopback model response, fresh home/config/data directories, and only the probe plugin. No API key or dependency installation is needed. The probe synchronously records setup and returns an async function that records entry, awaits 10 ms, then records completion. It has no event subscribers or background work.

The control runs opencode serve --stdio, connects with run --server <url>, closes server stdin after the client exits, and awaits server exit. A watchdog kill or failed control yields an inconclusive result.

Expected / actual

Expected: both paths record setup, cleanup-start, cleanup-end before exiting.

Observed on both tested OpenCode versions:

standalone: CLI exit=0, answer=done
cooperative: CLI exit=0, answer=done
standalone receipts: setup
cooperative receipts: setup, cleanup-start, cleanup-end
REPRODUCED: standalone exited without completing plugin cleanup.

Even the synchronous cleanup-entry receipt is missing. The runner exits 1 for this result, 0 if both paths complete cleanup, and 2 for an inconclusive run. Full instructions and evidence. Verified outside the project checkout without node_modules.

Environment
  • OpenCode: 2.4.2 and 2.0.26
  • OS: Windows x64, 10.0.26200
  • Runner: Bun 1.4.4; child processes launched directly, no interactive terminal involved
  • Plugin: only the local cleanup probe
Related project tracking
Langage dominant
TypeScript
Étoiles
230k
Forks
31.3k
Merge moyen
5 h 32 min
PR mergées (30 j)
453

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de anomalyco/opencode

Toutes les issues de anomalyco/opencode

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.