Safari Extension: The service_worker script failed to load due to an error.

I have updated my web extension to use Manifest v3. While trying to test, I get the error:

_The service_worker script failed to load due to an error. _

I do not see details on the error, or a place where to find details. Any suggestions?

Accepted Reply

I had a problem in my manifest.json, while porting I changed my manifest permission from contextMenus to context, this should be menus.

Replies

I had a problem in my manifest.json, while porting I changed my manifest permission from contextMenus to context, this should be menus.

Still having other issues causing a crash. Any clues on how to troubleshoot?

I know it's four months late but I ran into the same issue, I was able to debug mine properly by putting the extension inside of chrome and debugging there. It's stupid but seems like the only way.

Post not yet marked as solved Up vote reply of Down vote reply of

Same Problem here 😖 Is there a solution for this in the meantime?

Same problem for me but only when i run it on iOS, works fine on MacOS.

Same here. Converted from chrome to safari with xcrun ../dist -> works on iOS, crashes on macos with a grey background and no errors except when i toggle the extension, I'm getting: The service_worker script failed to load due to an error. Just print a error message, is that so complicated?

Loading into Chrome can be helpful, but I am at the point where Chrome accepts the whole extension just fine and Safari just won't load it for some reason it will not tell me. I am not even transitioning an existing extension I am start from scratch and having this issue.

Please if anyone has a way to make Xcode/Safari give a more helpful error, please post. I'll keep trying on my end, but this... is a weirdly frustrating blocker because it is probably something quite simple... but it won't tell me.

Yeah I have the same issue, a chrome extension and a safari extension but the error message in safari it totally unhelpful. How can we as developers identify the issue?

Same issue here.

I believe this is a bug in Safari. Safari MV3 supports the background.page key (so-called 'Event Pages') which you might be able to use as a workaround. Try something like

  • In manifest: background: {page: background.html}
  • In background.html: <script src="my_service_worker.js"></script>

Since incorporating my "service worker" like this I have stopped seeing the error (touch wood).