setInterval gets disrupted

I have a setInterval call in a background script. It gets disrupted by itself for some reason.

To reproduce this issue:

  1. Write a setInterval call in a background script.
  2. Open a concerned website whose access permission is configured in order to see running setInterval call.
  3. Open an another page on the same website on a new tab.
  4. Close the new tab so you get back to the first tab automatically.
  5. You will see the setInterval call no longer works without even errors.

Tested video reference:

It also doesn’t work in a content script. And I don’t have clearInterval call anywhere.

Maybe you are using Manifest V3 (or event background page) and your background script is killed?
Although it shouldn’t do that if the toolbox console is opened…

Post here your manifest file.

Thanks for your reply, @juraj.masiar

This is the manifest:

  "manifest_version": 2,
  "name": "Better Upwork",
  "description": "Better Upwork",
  "version": "2.8",
  "icons": {
    "16": "assets/icon-16.png",
    "32": "assets/icon-32.png",
    "48": "assets/icon-48.png",
    "128": "assets/icon-128.png"
  "permissions": [
  "browser_specific_settings": {
    "gecko": {
      "id": "",
      "strict_min_version": "88.0"
  "browser_action": {
    "default_icon": "assets/icon-64.png",
    "default_title": "Better Upwork",
    "default_popup": "popup/index.html"
  "background": {
    "scripts": [
  "content_scripts": [
      "matches": [
      "js": [

So, you are using persistent background page, so there is no reason for the setInterval to be stopped.

Note that you can stop the interval also with the clearTimeout call:

It’s worth noting that the pool of IDs used by setTimeout() and setInterval() are shared, which means you can technically use clearTimeout() and clearInterval() interchangeably. However, for clarity, you should avoid doing so.

And lastly, you have “.ts” files in the manifest, is that some new native TypeScript support I don’t know about? :smiley:

1 Like

@jasonmz, the steps you describe are a bit too abstract to meaningfully investigate. Specifically, there isn’t an implicit relationship between a setInterval call in the background and a content script.

Can you provide the source for either the extension shown in the video or a demo extension that reproduces the behavior?

1 Like