I’m running into a rare but recurring issue with my Chrome extension’s service worker and I’d like to get some feedback or insights.
Setup:
The extension uses a workaround to keep the service worker persistent and always active.
I have an offscreen script, and a content script on all pages, which communicate with the service worker using runtime messages.
The extension is mostly used on ChromeOS and deployed via GAC (Google Admin Console).
Problem:
Less than 1% of startups show problems where the service worker fails to activate. I’ve never been able to reproduce this myself, but I do see it in logs collected from chrome://serviceworker-internals. Importantly, the issue resolves itself if the user restarts their Chromebook, so it doesn’t appear to be user-specific.
Collected errors (longer loop that shows the extesnsion is trying to restart):
Error: {"columnNumber":-1,"lineNumber":-1,"message":"ServiceWorker startup timed out. The worker was in startup phase: Script streaming.","sourceURL":""}
Error: {"columnNumber":-1,"lineNumber":-1,"message":"DETACH_STALLED_IN_STOPPING","sourceURL":""}
Error: {"columnNumber":-1,"lineNumber":-1,"message":"ServiceWorker startup timed out. The worker was in startup phase: Script streaming.","sourceURL":""}
Error: {"columnNumber":-1,"lineNumber":-1,"message":"DETACH_STALLED_IN_STOPPING","sourceURL":""}
Error: {"columnNumber":-1,"lineNumber":-1,"message":"ServiceWorker startup timed out. The worker was in startup phase: Script streaming.","sourceURL":""}
Error: {"columnNumber":-1,"lineNumber":-1,"message":"DETACH_STALLED_IN_STOPPING","sourceURL":""}