fix(dashboard): logs auto-refresh reads live visibility, not a stale mount ref (#3972) (#3997)

The auto-refresh interval gated each tick on visibleRef, seeded once at mount and updated only by a visibilitychange event. A tab mounted while document.visibilityState is 'hidden' (background load, bfcache, embedded/proxied webviews) with no later visibilitychange left the ref false forever, so the interval ticked but never fetched — only the manual button worked. Read the live document.visibilityState in the tick instead.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-06-16 09:32:19 -03:00
committed by GitHub
parent 074f6188de
commit bb40fbba09
4 changed files with 153 additions and 2 deletions

View File

@@ -283,7 +283,12 @@ const RequestLoggerV2 = forwardRef<RequestLoggerV2Handle, { initialSelectedId?:
if (intervalRef.current) clearInterval(intervalRef.current);
if (!selectedLog && shouldAutoRefresh(recording, limit, PAGE_SIZE)) {
intervalRef.current = setInterval(() => {
if (visibleRef.current) fetchLogs(false);
// #3972: read live visibility each tick, not a mount-time ref. A tab
// mounted while "hidden" with no later `visibilitychange` left the ref
// false forever, so auto-refresh never ran (only the manual button did).
if (typeof document === "undefined" || document.visibilityState === "visible") {
fetchLogs(false);
}
}, refreshIntervalSec * 1000);
}
return () => {