Comments (3)
Perhaps you always have the developer console open for the extension? That prevents a service worker from terminating.
Service workers have a 30 second lifecycle. Received events or extension api calls reset the timer back to 30 seconds. If the timer expires, the service worker is terminated. Make sure there is no network activity, wait at least 30 seconds, and the extension will go 'inactive'. It will restart when an event it is listening to is fired. When it restarts, all the code in service-worker.js is run again.
There is no guarantee that the code in chrome.management.getAll will run before the listener for onRuleMatchedDebug when the extension restarts because of network activity. That is why the onRuleMatchedDebug listener needs to wait until the extension is fully initialized, before it continues. I've seen this error happen in this case:
Error in event handler: TypeError: Cannot read properties of undefined (reading 'numRequests') at chrome-extension://ojeaaldfoimnikjkigkhebdbpfjdoaco/service-worker.js:35:27
I can reproduce the error with the uBlock Origin extension. I let the service worker go inactive and open the 'uBlock Dashboard'. Then after selecting 'Filter lists', 'Purge all caches', and 'Update now', the error will appear when the extension restarts. If the service worker restarts on non extension network activity, then there would be no error.
There may be other cases in your code where you need the variables fully initialized first. I only looked at where the error occurred.
Note, new extensions can also be installed when the service worker is running. And you'll get an error in that same spot. This also needs to be considered. Maybe listen to management.onInstalled.
from little-rat.
I haven't been able to reproduce this. If you have more info, lmk. Gonna keep it open for a few days.
from little-rat.
Thank you for the detailed debugging! I'm working on some fixes.
from little-rat.
Related Issues (20)
- Data is lost when service worker stops (after 30 seconds of inactivity). HOT 3
- Line 41 in service-worker.js should increment badgeNum instead of set to 1
- Can I view detail on each network call ? HOT 1
- Feature request: Firefox support? HOT 7
- Feature request: Whitelist blacklist options HOT 2
- Feature request: Dark Mode
- Explain icons and numbers in the readme HOT 1
- Firefox support? HOT 1
- The full version for your extension works without problems, but the chrome version actually let connections going through HOT 1
- [full version] Toolbar icon gets count badge even when notifications are muted HOT 2
- A way to get and block requests of other extensions in firefox HOT 1
- little rat found a hidden extension, how can i delete it? HOT 2
- Feature Request: deplay all enabled extensions over disabled ones HOT 1
- (closed coz already implemented)Feature Request: Filter or Sort by historical internet access.
- Feature Request: more functions as an extension manager HOT 1
- Feature Request: Options to temporarily hide GET entries and count. HOT 2
- Feature Requests: Block extensions by default and mitigation in case the Little Rat extension crashes HOT 1
- [Feat] Don't open on startup (or offer an option for that) HOT 1
- Does blocking by URL actually work? HOT 12
- two suggestions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from little-rat.