From 2a4ccff96e296b5798cc7d22f0205c826f9aeae6 Mon Sep 17 00:00:00 2001 From: Supra4E8C Date: Thu, 12 Feb 2026 23:54:26 +0800 Subject: [PATCH] Prevent overlapping log auto-refresh requests --- src/pages/LogsPage.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pages/LogsPage.tsx b/src/pages/LogsPage.tsx index 80821f5..61f6c29 100644 --- a/src/pages/LogsPage.tsx +++ b/src/pages/LogsPage.tsx @@ -400,6 +400,8 @@ export function LogsPage() { startY: number; fired: boolean; } | null>(null); + const logRequestInFlightRef = useRef(false); + const pendingFullReloadRef = useRef(false); // 保存最新时间戳用于增量获取 const latestTimestampRef = useRef(0); @@ -424,6 +426,15 @@ export function LogsPage() { return; } + if (logRequestInFlightRef.current) { + if (!incremental) { + pendingFullReloadRef.current = true; + } + return; + } + + logRequestInFlightRef.current = true; + if (!incremental) { setLoading(true); } @@ -474,6 +485,11 @@ export function LogsPage() { if (!incremental) { setLoading(false); } + logRequestInFlightRef.current = false; + if (pendingFullReloadRef.current) { + pendingFullReloadRef.current = false; + void loadLogs(false); + } } };