Add a message when log channel is lagged

This commit is contained in:
Igor Katson 2023-12-09 14:03:42 +00:00
parent 1331145333
commit 37f295cb95
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
5 changed files with 18 additions and 7 deletions

View file

@ -18,7 +18,10 @@ webui-build: webui-deps
@PHONY: devserver @PHONY: devserver
devserver: devserver:
echo -n '' > /tmp/rqbit-log echo -n '' > /tmp/rqbit-log
CORS_DEBUG=1 cargo run --release -- --log-file /tmp/rqbit-log server start /tmp/scratch/ CORS_DEBUG=1 cargo run --release -- \
--log-file /tmp/rqbit-log \
--log-file-rust-log=debug,librqbit=trace \
server start /tmp/scratch/
@PHONY: clean @PHONY: clean
clean: clean:

View file

@ -3,13 +3,14 @@ use axum::body::Bytes;
use axum::extract::{Path, Query, State}; use axum::extract::{Path, Query, State};
use axum::response::IntoResponse; use axum::response::IntoResponse;
use axum::routing::{get, post}; use axum::routing::{get, post};
use futures::TryStreamExt;
use itertools::Itertools; use itertools::Itertools;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::net::SocketAddr; use std::net::SocketAddr;
use std::str::FromStr; use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use tracing::{info, warn}; use tracing::{debug, info, warn};
use axum::Router; use axum::Router;
@ -187,7 +188,10 @@ impl HttpApi {
} }
async fn stream_logs(State(state): State<ApiState>) -> Result<impl IntoResponse> { async fn stream_logs(State(state): State<ApiState>) -> Result<impl IntoResponse> {
let s = state.api_log_lines_stream()?; let s = state.api_log_lines_stream()?.map_err(|e| {
debug!(error=%e, "stream_logs");
e
});
Ok(axum::body::Body::from_stream(s)) Ok(axum::body::Body::from_stream(s))
} }

File diff suppressed because one or more lines are too long

View file

@ -4,7 +4,7 @@
"src": "assets/logo.svg" "src": "assets/logo.svg"
}, },
"index.html": { "index.html": {
"file": "assets/index-b804d1c8.js", "file": "assets/index-af1222d3.js",
"isEntry": true, "isEntry": true,
"src": "index.html" "src": "index.html"
} }

View file

@ -66,7 +66,7 @@ const streamLogs = (
text, text,
}, },
}); });
throw new Error("retry"); throw null;
} }
if (!response.body) { if (!response.body) {
@ -88,7 +88,7 @@ const streamLogs = (
setError({ setError({
text: "log stream terminated", text: "log stream terminated",
}); });
throw new Error("retry"); throw null;
} }
buffer = mergeBuffers(buffer, value); buffer = mergeBuffers(buffer, value);
@ -110,6 +110,10 @@ const streamLogs = (
if (canceled) { if (canceled) {
return; return;
} }
if (e === null) {
// We already set the error.
return;
}
setError({ setError({
text: "error streaming logs", text: "error streaming logs",
details: { details: {