Skip to content

clearIndexedDbPersistence gives 'window is not defined' error in service worker #6465

Closed
@GaurangTandon

Description

@GaurangTandon

Environment

  • Operating System version: Windows 10/Ubuntu 22.04
  • Browser version: Chrome 103/104/105
  • Firebase SDK version: 9.9.0
  • Firebase Product: firestore

Problem

Steps to reproduce

  1. Setup a Manifest V3 Chrome Extension with a service worker. (not necessary, see notes -> 1)
  2. Use enableIndexedDbPersistence(firebase, { forceOwnership: true }) in the service worker to setup persistence.
  3. Verify in the storage tab that indexeddb storage is enabled, great!
  4. Now, call clearIndexedDbPersistence() to remove all data from the indexeddb.

Actual result

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

Expected result

The indexed DB should be cleared.

Notes

  1. I don't think the problem is specific to MV3 Chrome extensions, but I don't have any other service worker environment to try this in.
  2. I had earlier asked a StackOverflow question for this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions