Skip to content

Commit

Permalink
Merge pull request #154 from cole-h/fixup-stream-error-logging
Browse files Browse the repository at this point in the history
fixup: stream error logging
  • Loading branch information
zhaofengli authored Aug 1, 2024
2 parents 6139576 + 903fb4e commit e127acb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/src/api/binary_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use axum::{
Router,
};
use futures::stream::BoxStream;
use http_body_util::BodyExt;
use futures::TryStreamExt as _;
use serde::Serialize;
use tokio_util::io::ReaderStream;
use tracing::instrument;
Expand Down Expand Up @@ -217,11 +217,11 @@ async fn get_nar(
match storage.download_file_db(remote_file, false).await? {
Download::Url(url) => Ok(Redirect::temporary(&url).into_response()),
Download::AsyncRead(stream) => {
let stream = ReaderStream::new(stream);
let body = Body::from_stream(stream).map_err(|e| {
let stream = ReaderStream::new(stream).map_err(|e| {
tracing::error!("Stream error: {e}");
e
}).into_inner();
});
let body = Body::from_stream(stream);

Ok(body.into_response())
}
Expand Down Expand Up @@ -254,11 +254,11 @@ async fn get_nar(

// TODO: Make num_prefetch configurable
// The ideal size depends on the average chunk size
let merged = merge_chunks(chunks, streamer, storage, 2);
let body = Body::from_stream(merged).map_err(|e| {
let merged = merge_chunks(chunks, streamer, storage, 2).map_err(|e| {
tracing::error!("Stream error: {e}");
e
}).into_inner();
});
let body = Body::from_stream(merged);

Ok(body.into_response())
}
Expand Down

0 comments on commit e127acb

Please sign in to comment.