Chrome extension background page inactive makes the extension run on 2 clicks

10,644

A background page can become inactive if it's declared as an Event page ( "persistent": false in the manifest).

Which probably means that you haven't set it up correctly if events are only handled after causing them twice.

Obvious solution: drop "persistent": false from the manifest. This is not recommended unless you use things that cannot work with Event pages (currently, mainly webRequest API)

Proper solution: see if your background script can be made into a proper Event page.

Share:
10,644
Haroon Dilshad
Author by

Haroon Dilshad

Updated on July 24, 2022

Comments

  • Haroon Dilshad
    Haroon Dilshad almost 2 years

    I have an extension which runs on a background page, the browserAction icon requires 2 clicks at max few seconds apart for the extension to start running background.js so I tried to see what's the issue, with chrome://extensions page loaded which states for my extension:Background page inactive. When I click one time the state changes to background page active and then the next click actually runs the extension, I couldn't see what's the issue, I use chrome.runtime.reload() at a couple of places, maybe that's the issue but what's the solution? Thanks in advance

  • Daniel Möller
    Daniel Möller almost 6 years
    Cool. A great solution is to use a "connection" as described in developer.chrome.com/extensions/messaging