File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @firebase/firestore ' : patch
3+ ' firebase ' : patch
4+ ---
5+
6+ Fix 'window is not defined' error when calling ` clearIndexedDbPersistence ` from a service worker
Original file line number Diff line number Diff line change 3131 " packages/util/dist/src/emulator.d.ts" ,
3232 " packages/util/dist/src/environment.d.ts" ,
3333 " packages/util/dist/src/compat.d.ts" ,
34+ " packages/util/dist/src/global.d.ts" ,
3435 " packages/util/dist/src/obj.d.ts" ,
3536 " packages/firestore/src/protos/firestore_bundle_proto.ts" ,
3637 " packages/firestore/src/protos/firestore_proto_api.ts" ,
Original file line number Diff line number Diff line change 1515 * limitations under the License.
1616 */
1717
18- import { getUA , isIndexedDBAvailable } from '@firebase/util' ;
18+ import { getGlobal , getUA , isIndexedDBAvailable } from '@firebase/util' ;
1919
2020import { debugAssert } from '../util/assert' ;
2121import { Code , FirestoreError } from '../util/error' ;
@@ -24,7 +24,7 @@ import { Deferred } from '../util/promise';
2424
2525import { PersistencePromise } from './persistence_promise' ;
2626
27- // References to `window ` are guarded by SimpleDb.isAvailable()
27+ // References to `indexedDB ` are guarded by SimpleDb.isAvailable() and getGlobal ()
2828/* eslint-disable no-restricted-globals */
2929
3030const LOG_TAG = 'SimpleDb' ;
@@ -164,7 +164,10 @@ export class SimpleDb {
164164 /** Deletes the specified database. */
165165 static delete ( name : string ) : Promise < void > {
166166 logDebug ( LOG_TAG , 'Removing database:' , name ) ;
167- return wrapRequest < void > ( window . indexedDB . deleteDatabase ( name ) ) . toPromise ( ) ;
167+ const globals = getGlobal ( ) ;
168+ return wrapRequest < void > (
169+ globals . indexedDB . deleteDatabase ( name )
170+ ) . toPromise ( ) ;
168171 }
169172
170173 /** Returns true if IndexedDB is available in the current environment. */
You can’t perform that action at this time.
0 commit comments