fix: prevent async generator cleanup errors in StreamableHTTP transport (#1271)
Some checks failed
Main branch checks / checks (push) Has been cancelled

Co-authored-by: David Soria Parra <167242713+dsp-ant@users.noreply.github.com>
This commit is contained in:
Moustapha Ebnou 2025-08-14 14:51:59 +02:00 • committed by GitHub
commit d1ac8d68eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -248,6 +248,7 @@ class StreamableHTTPTransport:
ctx.metadata.on_resumption_token_update if ctx.metadata else None,
)
if is_complete:
await event_source.response.aclose()
break
async def _handle_post_request(self, ctx: RequestContext) -> None:
@ -330,6 +331,7 @@ class StreamableHTTPTransport:
# If the SSE event indicates completion, like returning respose/error
# break the loop
if is_complete:
await response.aclose()
break
except Exception as e:
logger.exception("Error reading SSE stream:")