a2aproject / a2aproject/a2a-js

[Bug]: SSE clients silently drop events with standalone CR line endings

Aperta
#714 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
615
Fork
169
Merge medio
1g 6h
PR unite (30g)
21

Descrizione

## 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Esamina la logica di parsing SSE nel codice client/transport, probabilmente in `RestTransport` e `JsonRpcTransport`. Il caso di test è fornito; inizia configurando il fetch simulato con il corpo della risposta indicato. Esegui i test esistenti per vedere il fallimento, quindi modifica il parser in modo che gestisca i terminatori di riga CR autonomi come previsto dalla specifica HTML. Assicurati che la correzione gestisca anche i delimitatori suddivisi tra i confini dei chunk.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
backend-api-design, networking
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
65/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.