Skip to content

Commit 59f5d48

Browse files
Add onBlocked handler for schema upgrade
1 parent 3c064a3 commit 59f5d48

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/firestore/src/local/simple_db.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { PersistencePromise } from './persistence_promise';
2222
import { SCHEMA_VERSION } from './indexeddb_schema';
2323
import { Deferred } from '../util/promise';
2424
import { PersistenceTransaction } from './persistence';
25+
import { Code, FirestoreError } from '../util/error';
2526

2627
const LOG_TAG = 'SimpleDb';
2728

@@ -62,6 +63,15 @@ export class SimpleDb {
6263
resolve(new SimpleDb(db));
6364
};
6465

66+
request.onblocked = () => {
67+
reject(
68+
new FirestoreError(
69+
Code.FAILED_PRECONDITION,
70+
'Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed.'
71+
)
72+
);
73+
};
74+
6575
request.onerror = (event: ErrorEvent) => {
6676
reject((event.target as IDBOpenDBRequest).error);
6777
};

0 commit comments

Comments
 (0)