Do This Before Publishing Your Chrome Extension
Before you publish your chrome extension on the Chrome Web Store, make sure that you don't have any bugs in your code. Development and production environments aren't always identical.
Table of Contents 📖
Service Worker Lifecycle
If you have ever developed a chrome extension, you may have noticed that service workers do not stay alive permanently. Instead, they shut down after 30 seconds of inactivity. This may introduce bugs into your extension as, when developing an extension, you are consistently updating the service worker code, refreshing the extension, all things that extend the life of the service worker. This means that your extension development environment isn't identical to production.
Service Worker Management
To make sure your extension is working as expected in production, you should experiment with stopping and starting the service worker. This can be done at the following URL:
chrome://serviceworker-internals/
On this page, search for your extension ID and click on the "Stop" button. This will set your service worker to "inactive". After doing this, experiment with your extension. Is there any data loss? Are listeners firing? Have listeners been removed? Stop and start your service worker again and check everything is working accordingly.
ERROR: Global variables are lost when the service worker shuts down.