Here is a background script for a Chrome extension. It counts requests and logs the total every few seconds.
// background.js
let requestCount = 0;
chrome.webRequest.onBeforeRequest.addListener(() => { requestCount++; });
setInterval(() => { console.log(`seen ${requestCount} requests`); }, 5000);
It works. You load the extension, browse a few pages, watch the count climb, ship it. A week later users report the log stopped and the count is stuck at 0. Nothing in your code changed.
Top comments (0)