Skip to content

Commit

Permalink
Fix an issue where LLM requests would block forever (#18830)
Browse files Browse the repository at this point in the history
Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <[email protected]>
  • Loading branch information
mikayla-maki and maxdeviant authored Oct 7, 2024
1 parent 8cdb9d6 commit 5387a6f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy_collab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Publish Collab Server Image
on:
push:
tags:
# Pause production deploys while we investigate an issue.
# - collab-production
- collab-production
- collab-staging

env:
Expand Down
27 changes: 25 additions & 2 deletions crates/reqwest_client/src/reqwest_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ impl futures::stream::Stream for WrappedBody {
WrappedBodyInner::SyncReader(cursor) => {
let mut buf = Vec::new();
match cursor.read_to_end(&mut buf) {
Ok(_) => {
return Poll::Ready(Some(Ok(Bytes::from(buf))));
Ok(bytes) => {
if bytes == 0 {
return Poll::Ready(None);
} else {
return Poll::Ready(Some(Ok(Bytes::from(buf))));
}
}
Err(e) => return Poll::Ready(Some(Err(e))),
}
Expand Down Expand Up @@ -234,3 +238,22 @@ impl http_client::HttpClient for ReqwestClient {
.boxed()
}
}

#[cfg(test)]
mod test {

use core::str;

use http_client::AsyncBody;
use smol::stream::StreamExt;

use crate::WrappedBody;

#[tokio::test]
async fn test_sync_streaming_upload() {
let mut body = WrappedBody::new(AsyncBody::from("hello there".to_string())).fuse();
let result = body.next().await.unwrap().unwrap();
assert!(body.next().await.is_none());
assert_eq!(str::from_utf8(&result).unwrap(), "hello there");
}
}

0 comments on commit 5387a6f

Please sign in to comment.