Skip to content
Discussion options

You must be logged in to vote

This is a well-known gap between how browser-based timer APIs work and how OS-level suspend/resume behaves, and it's especially sharp in Electron tray apps since there's no natural "window focus" event to bail you out.

Root Cause

refetchInterval under the hood uses setInterval (via TanStack Query's timeoutManager). When the OS suspends (sleep/hibernate), the JS event loop is frozen. On resume, setInterval callbacks don't retroactively fire for missed ticks. They just resume on their normal cadence, meaning your first refetch after an 8-hour sleep might not happen for another full interval cycle.

On top of that, refetchOnWindowFocus relies on visibilitychange events, and refetchOnReconnect

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@setchy
Comment options

Answer selected by setchy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants