fix: don't respond to cancelled requests (#957)

* fix: don't respond to cancelled requests

* chore: remove redundant comment

* fix: update SSE stream constructor
This commit is contained in:
Dale Seo 2026-07-08 11:24:36 -04:00 • committed by GitHub
commit dbda50c0eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 218 additions and 5 deletions

View file

@ -1103,9 +1103,11 @@ where
JsonRpcMessage::Error(error) => error.id.as_ref(),
_ => None,
} {
if let Some(ct) = local_ct_pool.remove(id) {
ct.cancel();
}
let Some(ct) = local_ct_pool.remove(id) else {
tracing::debug!(%id, "dropping response for cancelled request");
continue;
};
ct.cancel();
let send = transport.send(m);
let current_span = tracing::Span::current();
response_send_tasks.spawn(async move {

View file

@ -84,7 +84,7 @@ impl StreamableHttpClient for reqwest::Client {
return Err(StreamableHttpError::UnexpectedContentType(None));
}
}
let event_stream = SseStream::from_byte_stream(response.bytes_stream()).boxed();
let event_stream = SseStream::from_bytes_stream(response.bytes_stream()).boxed();
Ok(event_stream)
}
@ -223,7 +223,7 @@ impl StreamableHttpClient for reqwest::Client {
}
match content_type.as_deref() {
Some(ct) if ct.as_bytes().starts_with(EVENT_STREAM_MIME_TYPE.as_bytes()) => {
let event_stream = SseStream::from_byte_stream(response.bytes_stream()).boxed();
let event_stream = SseStream::from_bytes_stream(response.bytes_stream()).boxed();
Ok(StreamableHttpPostResponse::Sse(event_stream, session_id))
}
Some(ct) if ct.as_bytes().starts_with(JSON_MIME_TYPE.as_bytes()) => {