The Firestore enableIndexedDbPersistence
allows us to specify forceOwnership: true
to specify that we're in a service worker context. This works great in MV3 Chrome Extension service worker. It starts the IndexedDB and I'm able to view the stored data in extension context.
However, when I call clearIndexedDbPersistence
, it fails because of "window
is not defined" errors. The exact trace is this but it is probably not relevant:
Uncaught (in promise) ReferenceError: window is not defined
at Yl.delete (index.esm2017.js:6055:59)
at index.esm2017.js:16720:26
at index.esm2017.js:16717:19
at index.esm2017.js:16308:54
To repro the issue, simply call clearIndexedDbPersistence()
a few seconds after the call to enableIndexedDbPersistence(firebase, { forceOwnership: true })
has finished, in a service worker in a MV3 Chrome extension.
Is there a temporary workaround, or a flag in Firestore, that will make this work? I did not find any open issues about this, so it is possible I am missing something, but I don't see what that could be.