Why setInterval Dies at 30 Seconds in Manifest V3
The badge froze at 12:33. The session timer had been ticking every second in the background worker, and after I switched tabs for half a minute it simply stopped — no exception, no console error, just a stale number in the toolbar. That "30 seconds" is not a limit on setInterval . It is the service worker's idle timeout, and it applies to everything the worker owns. The short version MV3…
In Manifest V3, the setInterval function fails after 30 seconds of inactivity in a background service worker. This is not due to a built-in limit on setInterval, but rather the worker's idle timeout, which affects any task owned by the worker. The 30-second period refers to a timer that the worker starts when it begins running. Extension events and API calls reset this timer, but once it expires, the worker is terminated and its resources, including interval handles, are lost.
Therefore, any task requiring persistence beyond 30 seconds should be handled differently. A recommended alternative is to use chrome.alarms to create an alarm that can last longer than the idle timeout. Extension handlers can run for up to five minutes, but this does not impact the operation of setInterval. The key takeaway is to use chrome.alarms for tasks that must persist beyond the idle timeout, and to manage timers at the alarm cadence rather than every second.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.