SDK streaming iterators leave their response bodies open on early exit
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 57/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- node.js, typescript
- Domínio
- api, backend-api-design
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 2.2k
- Forks
- 187
- Merge médio
- 2h 19min
- PRs com merge (30d)
- 2
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de MiniMax-AI/cli
-
[Bug] 未登录时 mmx help 被认证检查拦截,无法查看公开文档链接Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
MiniMax-AI/cli#259 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[Bug] --no-color 未去除请求状态栏的 ANSI 颜色Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
MiniMax-AI/cli#258 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 63/100
MiniMax-AI/cli#278 ·
Mantenedores costumam responder em até 1 dia
-
/compact commandAberta
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
MiniMax-AI/cli#275 ·
Mantenedores costumam responder em até 1 dia
-
[Security] Six confirmed vulnerabilities remain in latest mainTalvez já em andamento @rahmaniramin550-ai assumiu há 7 dias. Aberta
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
MiniMax-AI/cli#273 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de MiniMax-AI/cli
Issues semelhantes
-
[Docs] README: FAQ setup command, IDA in the intro, Node badgeTalvez já em andamento @akram1089 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
morluto/rea#1353 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked filesAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
maniator/verticopolis#880 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
siyuan-note/siyuan#20353 ·
Mantenedores costumam responder em até 1 dia
-
afk-ok area:data-quality importer size:S
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
enorm-labs/event-junkie#3027 ·
Mantenedores costumam responder em até 1 dia