Failed to register/update a ServiceWorker

As of Firefox 103 I’m getting the error: “Failed to register/update a ServiceWorker for scope ': Storage access is restricted in this context due to user settings or private browsing mode.”

The service worker worked fine on previous versions of Firefox and still works in the latest version of Chrome.

I’ve found that I can work around this by adding an exception for the site in Exceptions - Cookies and Site Data. However doing this manually is really not ideal.

I have 2 questions:

1: Can anyone tell me the reasons why Firefox might be doing this for my site?
2: Is it possible to add cookie exceptions via settings?

A bit of background - this is not a “normal” usecase.
The site in questions is actually the ZAP HUD, and we have an open issue here:
We can launch Firefox from ZAP so changing the Firefox settings is not too bad, although it wont help users who want to run Firefox ‘manually’.

Hi Simon!

This is most likely happening because we currently disable service workers in third-party contexts when Total Cookie Protection (Fx103) is enabled. We plan to roll out a change in the future to allow access to partitioned service workers, but that isn’t enabled in Firefox release quite yet.
On the Firefox side you can try to set privacy.partition.serviceWorkers to true and see if it fixes the issue.

On the web app side you can work around this by request first party storage access via the Storage Access API like you mentioned here:

For this call you’ll need user activation. Calling requestStorageAccess on click in the iframe would work.
Once the third-party service worker has first-party storage access it should work normally.
1 Like

Thanks @pbz - flipping the privacy.partition.serviceWorkers pref has helped. Things still arent working right but its progress and I have a new set of error messages to investigate :wink:

Glad it’s helpful!

Here is the bug for turning on service worker partitioning by default:

With that pref the service worker should be able to register in the third-party context, however if it needs non-partitioned storage access you’d still need to use the Storage Access API to request that.