a2aproject / a2aproject/a2a-js
[Bug]: SSE clients silently drop events with standalone CR line endings
- Langage dominant
- TypeScript
- Étoiles
- 615
- Forks
- 169
- Merge moyen
- 1 j 6 h
- PR mergées (30 j)
- 21
Description
## 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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Examinez la logique d’analyse SSE dans le code client/transport, probablement dans `RestTransport` et `JsonRpcTransport`. Le cas de test est fourni ; commencez par configurer le fetch simulé avec le corps de réponse indiqué. Exécutez les tests existants pour voir l’échec, puis modifiez l’analyseur afin qu’il gère les fins de ligne CR autonomes conformément à la spécification HTML. Assurez-vous que la correction gère également les délimiteurs répartis entre plusieurs chunks.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- backend-api-design, networking
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Active
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 65/100