a2aproject / a2aproject/a2a-js
[Bug]: SSE clients silently drop events with standalone CR line endings
- Lenguaje dominante
- TypeScript
- Estrellas
- 615
- Forks
- 169
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 21
Descripción
## What happened
JSON-RPC and HTTP+JSON clients silently yield no updates when a valid SSE response uses standalone CR (`\r`) line endings. The same event works with LF (`\n`) or CRLF (`\r\n`). A finite response completes without an error or an event.
## What I expected
All three SSE line endings should deliver the same task update, including when line delimiters cross network chunk boundaries.
## Steps to reproduce
1. Create a `RestTransport` with a mock fetch returning HTTP 200 and `Content-Type: text/event-stream`.
2. Use this response body (JavaScript string literal):
```js
'data: {"task":{"id":"task-1","contextId":"ctx-1","status":{"state":"TASK_STATE_WORKING"}}}\r\r'
```
3. Iterate `resubscribeTask({ id: 'task-1', tenant: '' })` until completion. It yields **0** events.
4. Replace `\r\r` with `\n\n` or `\r\n\r\n`. Both yield **1** event.
5. Repeat with `JsonRpcTransport`, wrapping the task payload in `{ jsonrpc: '2.0', id: , result: }`. The results are identical.
## Additional context
Reproduced with the response split into one-byte chunks; the relevant client/parser code matches upstream main `ae20aca7d6fbc94c839a37d945ec637642289227`.
The HTML SSE standard explicitly allows CRLF, LF, and standalone CR as line endings:
https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
This can silently discard task updates from a conforming remote agent. Please cover standalone CR as well as split CRLF delimiters, so adding CR support does not introduce duplicate event boundaries.
Guía de contribución
Línea de trabajo
Revisa la lógica de análisis de SSE en el código de cliente/transporte, probablemente en `RestTransport` y `JsonRpcTransport`. El caso de prueba está proporcionado; empieza configurando el fetch simulado con el cuerpo de respuesta indicado. Ejecuta las pruebas existentes para ver el fallo y, después, modifica el analizador para que gestione finales de línea CR independientes según la especificación de HTML. Asegúrate de que la corrección también gestione delimitadores divididos entre los límites de los chunks.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- backend-api-design, networking
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 65/100