SDK streaming iterators leave their response bodies open on early exit
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 57/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
- Ambito
- api, backend-api-design
Direzione di ricerca
Start with src/sdk/client.ts and src/client/stream.ts, then compare the cleanup in transcribeStream() in src/sdk/speech/index.ts. Check the existing stream tests and add regression coverage for early exit and [DONE], while preserving normal EOF and read-error behavior. Done means SDK-owned response bodies are cancelled when iteration stops early and reader locks are released.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
At main commit 06e47c70b76f419196678367dae62acca4c94076, the streaming implementations of text.chat() and speech.synthesize() create an HTTP response internally and delegate to Client.streamSSE(). If a caller stops consuming after an event, the iterator exits without cancelling that response body. The caller receives only the iterator, so cannot directly cancel the internal response.
Client.streamSSE() also breaks on [DONE] without cleanup. Its underlying parseSSE() only releases the reader lock in finally.
Offline reproduction of the shared parser path
Run from the repository root with Node.js 24.19.0. This imports unchanged source and makes no API request:
node --input-type=module <<'JS'
import { parseSSE } from './src/client/stream.ts';
let cancelled = false;
const body = new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode('data: first\n\n'));
},
cancel() { cancelled = true; },
});
for await (const event of parseSSE(new Response(body))) {
console.log(event.data);
break;
}
console.log({ cancelled, locked: body.locked });
await body.cancel(); // Clean up the deliberately open probe stream.
JS
Actual output:
first
{ cancelled: false, locked: false }
A separate loopback HTTP check of the same parser confirmed that the server continued sending events after the consumer exited; explicitly calling response.body.cancel() then closed the connection. Normal EOF and original read-error propagation passed as controls. These checks used synthetic data and no credentials or paid API calls; they do not establish provider-side generation or billing behavior.
Proposed scope
Would you accept a focused fix to release SDK-owned SSE responses when iteration stops early, including the helper's [DONE] path? I would like to confirm whether you prefer cleanup in Client.streamSSE() or in the shared parser, since a direct parser caller supplies its own Response.
The transcribeStream() wrapper already cancels its body on exit for this reason. Regression coverage could include early break/return, [DONE], normal EOF, read failures and rejecting cleanup, while preserving existing errors and releasing reader locks.
AI assistance was used for source inspection and local reproduction. No fix has been implemented or submitted. Open #276 changes line-ending parsing in the same parser; its current patch does not add response cleanup.
- Lingua principale
- TypeScript
- Stelle
- 2.2k
- Fork
- 187
- Merge medio
- 2h 19m
- PR unite (30g)
- 2
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MiniMax-AI/cli
-
[Bug] 未登录时 mmx help 被认证检查拦截,无法查看公开文档链接Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
MiniMax-AI/cli#259 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] --no-color 未去除请求状态栏的 ANSI 颜色Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
MiniMax-AI/cli#258 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 63/100
MiniMax-AI/cli#278 ·
I maintainer di solito rispondono entro 1 giorno
-
/compact commandAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
MiniMax-AI/cli#275 ·
I maintainer di solito rispondono entro 1 giorno
-
[Security] Six confirmed vulnerabilities remain in latest mainForse già presa @rahmaniramin550-ai l’ha presa 7 giorni fa. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
MiniMax-AI/cli#273 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MiniMax-AI/cli
Issue simili
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
lingdojo/kana-dojo#32018 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
paperclipai/paperclip#15751 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
BuilderIO/agent-native#7275 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno