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:
parent
45f2f72881
commit
dbda50c0eb
2 changed files with 218 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue