Background scripts or service workers terminate when not in use
Why it matters
MV3 service workers that never terminate because of setInterval or persistent WebSocket connections consume CPU and memory continuously — for every browser session, on every user's machine. ISO 25010:2011 performance-efficiency.resource-utilisation treats unkillable background processes as a resource defect. Chrome aggressively terminates service workers that misbehave, but a setInterval pattern keeps the worker alive indefinitely, preventing Chrome's idle eviction from ever firing. This drains battery on laptops and degrades overall system performance.
Severity rationale
High because a background script that never terminates imposes a permanent CPU and memory tax on every user's browser, measurably degrading battery life.
Remediation
Replace setInterval with chrome.alarms so the service worker performs its work and exits, relying on Chrome to wake it when the next alarm fires.
// BAD: prevents service worker termination
setInterval(() => checkForUpdates(), 60_000);
// GOOD: service worker wakes on alarm, runs, then idles naturally
chrome.alarms.create('updateCheck', { periodInMinutes: 1 });
chrome.alarms.onAlarm.addListener((alarm) => {
if (alarm.name === 'updateCheck') checkForUpdates();
});
For MV2 extensions, set "persistent": false in manifest.json unless the extension genuinely requires a persistent WebSocket or audio context — document the reason in a comment if true is unavoidable.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Extension UX & Performance Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · performance-efficiency.resource-utilization
Taxons
History
- 2026-04-18·v1.0.0·Initial import from extension-ux-performance·automated