Skip to content

Commit daf9469

Browse files
committed
Keep SSE reconnect tests fast and document stable errors
1 parent 3e831d6 commit daf9469

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎docs/client/transports.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Pass `max_sse_event_size` when a server sends a large tool result or notificatio
5656

5757
The default is 1 MiB per event, measured in bytes before the event is parsed. The limit applies to
5858
POST responses, the GET stream, and resumed streams. An oversized event in a POST response or resumed
59-
stream fails that request with an error naming the limit. On the background GET stream, the client logs
59+
stream fails that request with an SSE error. On the background GET stream, the client logs
6060
the error and retries the stream. Set `max_sse_event_size=None` to disable the cap when you trust the
6161
server and need larger events. JSON responses are unaffected. If you use `ClientSessionGroup`, set the
6262
same option on `StreamableHttpParameters`.

‎tests/client/test_streamable_http.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,12 @@ def handler(request: httpx2.Request) -> httpx2.Response:
175175
if request.method == "GET":
176176
gets.append(request)
177177
if len(gets) == 1:
178-
content = b'data: {"jsonrpc":"2.0","method":"notifications/message","params":{"data":"'
178+
content = b'retry: 0\n\ndata: {"jsonrpc":"2.0","method":"notifications/message","params":{"data":"'
179179
content += b"x" * 2048 + b'"}}\n\n'
180-
else:
180+
elif len(gets) == 2:
181181
content = b'data: {"jsonrpc":"2.0","method":"notifications/message","params":{"data":"ok"}}\n\n'
182+
else:
183+
return httpx2.Response(500)
182184
return httpx2.Response(200, content=content, headers={"content-type": "text/event-stream"})
183185
body = json.loads(request.content)
184186
if body.get("method") == "initialize":

0 commit comments

Comments
 (0)