test(api-server): _read_sse_frame skips comment-only frames
The run-events stream now flushes a ': open' comment frame before the first event (#80757). SSE consumers dispatch nothing for comment-only frames; the reconnect test's reader must do the same instead of returning an empty first frame.
This commit is contained in:
@@ -165,14 +165,18 @@ def _make_scripted_agent():
|
||||
|
||||
|
||||
async def _read_sse_frame(response):
|
||||
"""Read the next event frame; comment-only frames (``: open``) dispatch nothing in SSE."""
|
||||
lines = []
|
||||
while True:
|
||||
line = await response.content.readline()
|
||||
if not line:
|
||||
break
|
||||
lines.append(line.decode())
|
||||
if line == b"\n":
|
||||
break
|
||||
if any(not entry.startswith(":") for entry in lines):
|
||||
break
|
||||
lines = []
|
||||
continue
|
||||
lines.append(line.decode())
|
||||
sequence = next(
|
||||
(int(line.removeprefix("id: ")) for line in lines if line.startswith("id: ")),
|
||||
None,
|
||||
|
||||
Reference in New Issue
Block a user