Search code examples
google-chrome-extensionchrome-extension-manifest-v3

Chrome Extension callback when restarted or shut down


Is there a chrome extension callback to detect when an extension is restarted or the browser is closed?

I see chrome.runtime.onSuspend but can not get that to be called.


Solution

  • Is there a chrome extension callback to detect when an extension is restarted

    Yes, chrome.runtime.onStartup will fire when the extension is loaded for any reason, e.g. the browser is started or the extension is restarted.

    or the browser is closed?

    No, you don't get any event in this case. Chrome won't wait for extensions if the last window of the browser is requested to close.

    chrome.runtime.onSuspend is only for the non-persistent event pages unloading while the browser continues to run.