Chrome Terminates Idle Service Workers, Silently Cancelling Extension setTimeout Calls
A developer found that a scheduled sync in a Chrome extension never ran, with no error or warning logged. The cause was not the timer logic but the browser's execution model: a Manifest V3 background service worker is terminated after roughly 30 seconds of inactivity, and any pending setTimeout dies with it. Pending timers do not count as activity, so longer delays survive only if other events happen to wake the worker. The recommended fix is to persist the due timestamp in storage and use chrome.alarms with an absolute time, re-arming it on worker startup. For UI-scoped work, moving the timer into the content script is suggested, while keep-alive pings are discouraged as wasteful and likely to draw review scrutiny.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in