[fix](trx-frontend-http): compress images and fix SSE heartbeat timing
Resize favicon from 1024x1024 to 64x64 and logo from 1024x1024 to 256x256, reducing total image size from ~3 MB to ~70 KB. Fix SSE heartbeat race condition where the 10s ping interval competed with the 8s stale threshold, causing spurious reconnects. Now pings every 5s server-side, with a 15s stale threshold and 5s check interval client-side. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 62 KiB |
@@ -289,11 +289,11 @@ es.onmessage = (evt) => {
|
||||
|
||||
esHeartbeat = setInterval(() => {
|
||||
const now = Date.now();
|
||||
if (now - lastEventAt > 8000) {
|
||||
if (now - lastEventAt > 15000) {
|
||||
es.close();
|
||||
connect();
|
||||
}
|
||||
}, 4000);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
async function postPath(path) {
|
||||
|
||||
@@ -48,7 +48,7 @@ pub async fn events(state: web::Data<watch::Receiver<RigState>>) -> Result<HttpR
|
||||
.map(|json| Ok::<Bytes, Error>(Bytes::from(format!("data: {json}\n\n"))))
|
||||
});
|
||||
|
||||
let pings = IntervalStream::new(time::interval(Duration::from_secs(10)))
|
||||
let pings = IntervalStream::new(time::interval(Duration::from_secs(5)))
|
||||
.map(|_| Ok::<Bytes, Error>(Bytes::from(": ping\n\n")));
|
||||
|
||||
let stream = initial_stream.chain(select(pings, updates));
|
||||
|
||||
Reference in New Issue
Block a user