Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

opencode api truncates large output when stdout is a pipe (un-awaited write before process.exit)

Chiusa Adatta ai principianti
#57,816 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, typescript
Ambito
cli

Direzione di ricerca

Leggi packages/cli/src/commands/handlers/api.ts e packages/cli/src/index.ts per tracciare la scrittura su stdout e l’exit tap. Riproduci il problema inviando opencode api GET /openapi.json a wc -c, quindi verifica che l’output completo venga scritto prima dell’uscita. Il problema è risolto quando l’output convogliato è completo e la CLI termina correttamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

pending close triaging

Version: opencode v2.0.32 (source read at that tag); the same write is still on the default branch
(packages/cli/src/commands/handlers/api.ts:46, fetched 2026-10-21).

Reproduce

for i in $(seq 10); do opencode api GET /openapi.json | wc -c; done   # 280292 bytes expected
opencode api GET /openapi.json > out.json; wc -c out.json            # always 280292

Piped, the count stops at exactly 262144 with exit status 0 in 1 of 8 and 4 of 10 runs (Linux, v2.0.32).
Redirected to a file it is complete every time. The silent exit 0 is what makes it hard to notice.

Cause (v2.0.32)

  • packages/cli/src/commands/handlers/api.ts:45-46: the handler reads response.text() and calls
    process.stdout.write(output + ...) once, with no callback and no drain.
  • packages/cli/src/index.ts:139: Effect.tap(() => Effect.sync(() => process.exit(process.exitCode ?? 0)))
    runs right after the handler.
  • Under Bun a write to a pipe larger than the pipe buffer is asynchronous, so process.exit discards what
    the reader has not drained. A write to a file is synchronous, hence complete. 262144 is the pipe buffer
    size, not a number in the source.

Suggested fix: wait for the write before exiting, e.g.
yield* Effect.promise(() => new Promise<void>((done) => process.stdout.write(out, () => done())))
in the handler, or have the exit tap wait for stdout to drain.

Workaround we use: redirect stdout to a file, never a pipe.

Lingua principale
TypeScript
Stelle
215k
Fork
28.9k
Merge medio
4h 21m
PR unite (30g)
476

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anomalyco/opencode

Tutte le issue di anomalyco/opencode

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.