SafariExtensions
SafariExtensions copied to clipboard
Service worker fails to load after disabling and re-enabling the extension
In my Manifest v3 extension, rapidly unticking and re-ticking the checkbox to disable/re-enable the extension causes a permanent failure to load the service worker.
I was able to stop this happening by removing my onInstalled
handler. Reducing the number of async functions in this handler made it less likely to occur. I'd speculate the crash occurs when the extension is disabled before that handler has finished running.
When the handler included calls to browser.storage.local
I would occasionally see the following error message logged by the service worker:
Unhandled Promise Rejection: Error: disk I/O error: disk I/O error: SELECT SUM(LENGTH(key) + LENGTH(value)) FROM extension_storage
Tested with Safari 16.4, 17 Beta, MacOS Ventura