Skip to content

Commit

Permalink
Merge pull request #137 from cole-h/log-stream-errors
Browse files Browse the repository at this point in the history
Log stream errors
  • Loading branch information
zhaofengli authored Jun 1, 2024
2 parents 3907b31 + a4f2cae commit 0558269
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server/src/api/binary_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::io::{Error as IoError, ErrorKind as IoErrorKind};
use std::path::PathBuf;
use std::sync::Arc;

use axum::body::HttpBody as _;
use axum::{
body::StreamBody,
extract::{Extension, Path},
Expand Down Expand Up @@ -217,7 +218,11 @@ async fn get_nar(
Download::Url(url) => Ok(Redirect::temporary(&url).into_response()),
Download::AsyncRead(stream) => {
let stream = ReaderStream::new(stream);
let body = StreamBody::new(stream);
let body = StreamBody::new(stream).map_err(|e| {
tracing::error!("Stream error: {e}");
e
});

Ok(body.into_response())
}
}
Expand Down Expand Up @@ -250,7 +255,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 = StreamBody::new(merged);
let body = StreamBody::new(merged).map_err(|e| {
tracing::error!("Stream error: {e}");
e
});

Ok(body.into_response())
}
}
Expand Down

0 comments on commit 0558269

Please sign in to comment.