a2aproject / a2aproject/a2a-js
[Bug]: SSE clients silently drop events with standalone CR line endings
- Vorherrschende Sprache
- TypeScript
- Sterne
- 615
- Forks
- 169
- Ø Merge
- 1 T. 6 Std.
- Gemergte PRs (30 T.)
- 21
Beschreibung
## 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.
Beitragsleitfaden
Rechercherichtung
Sieh dir die SSE-Parsing-Logik im Client-/Transport-Code an, wahrscheinlich in `RestTransport` und `JsonRpcTransport`. Der Testfall ist vorhanden; richte zunächst den Mock-Fetch mit dem angegebenen Response-Body ein. Führe die vorhandenen Tests aus, um den Fehler zu sehen, und passe dann den Parser so an, dass er eigenständige CR-Zeilenenden gemäß der HTML-Spezifikation verarbeitet. Stelle sicher, dass der Fix auch geteilte Trennzeichen über Chunk-Grenzen hinweg verarbeitet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- backend-api-design, networking
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 65/100