Prevent overlapping log auto-refresh requests

This commit is contained in:
Supra4E8C
2026-02-12 23:54:26 +08:00
parent b5f869ed25
commit 2a4ccff96e

View File

@@ -400,6 +400,8 @@ export function LogsPage() {
startY: number; startY: number;
fired: boolean; fired: boolean;
} | null>(null); } | null>(null);
const logRequestInFlightRef = useRef(false);
const pendingFullReloadRef = useRef(false);
// 保存最新时间戳用于增量获取 // 保存最新时间戳用于增量获取
const latestTimestampRef = useRef<number>(0); const latestTimestampRef = useRef<number>(0);
@@ -424,6 +426,15 @@ export function LogsPage() {
return; return;
} }
if (logRequestInFlightRef.current) {
if (!incremental) {
pendingFullReloadRef.current = true;
}
return;
}
logRequestInFlightRef.current = true;
if (!incremental) { if (!incremental) {
setLoading(true); setLoading(true);
} }
@@ -474,6 +485,11 @@ export function LogsPage() {
if (!incremental) { if (!incremental) {
setLoading(false); setLoading(false);
} }
logRequestInFlightRef.current = false;
if (pendingFullReloadRef.current) {
pendingFullReloadRef.current = false;
void loadLogs(false);
}
} }
}; };