-
Notifications
You must be signed in to change notification settings - Fork 926
clearIndexedDbPersistence gives 'window is not defined' error in service worker #6465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi team! Is there any update on this issue? In the mean time, is there any other alternative code so as to manually clear the Firebase IndexedDB ourselves? |
Hi @GaurangTandon , sorry for the long wait on this ticket. I assume you are using a newer version of the Firebase SDK( not the v9.9.0 in the description) and the problem still exists, correct? Could you please provide a minimal repro app to reproduce this error? |
Hi @milaGGL I am still able to reproduce the issue on the latest version. The stack trace has changed to this now:
I have added a minimal repro at this drive link: https://drive.google.com/file/d/1QUBEMtaoEf4SHSa2j3yORWn739nDd4_9/view?usp=sharing After you download the zip file, here's a video showing step by step to repro the issue: https://github.com/firebase/firebase-js-sdk/assets/6308683/69f6f094-b7db-43f6-b34a-7879717a379c You can swap manifest.json contents with mv2.json/mv3.json (as I have done in the video) and observe the error in mv3 version. This is because mv3 version uses a service worker (which doesn't have a window defined globally), whereas mv2 version does have window defined globally. |
@GaurangTandon, I am able to reproduce this error, will start looking into the root cause ASAP. |
Hi @milaGGL just checking in to see if there was any update on this issue? |
I think if we change this line:
to: return wrapRequest<void>(indexedDB.deleteDatabase(name)).toPromise(); That would fix the problem. Note that we reference
So it would make sense to do the same on line 166. What do you think? |
Hi! Sorry for bumping this again, but it looks like this is a relatively simple one-line change that would fix the issue. If that sounds fine, I'm happy to send a PR for this alongside some tests. Please let me know. |
Hi @GaurangTandon, the fix is merged and should be available with the next release. Thank you for reporting this issue and looking into the cause. Please let me know if the upcoming new release has resolved the issue. |
Thanks a lot for the swift response @milaGGL ! 😄 I will try the new release as soon as it's available |
Environment
Problem
Steps to reproduce
enableIndexedDbPersistence(firebase, { forceOwnership: true })
in the service worker to setup persistence.clearIndexedDbPersistence()
to remove all data from the indexeddb.Actual result
Expected result
The indexed DB should be cleared.
Notes
The text was updated successfully, but these errors were encountered: