Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

SDK streaming iterators leave their response bodies open on early exit

Abierto
#277 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@dvd233 ya está trabajando en esto.

Desde el 6/10/2026.

  • #279 de @dvd233 — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
57/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
node.js, typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
2.2k
Forks
187
Merge medio
2 h 19 min
PR fusionados (30 d)
2

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MiniMax-AI/cli

Todos los issues de MiniMax-AI/cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.