Skip to content

Commit 189bcea

Browse files
Add onBlocked handler for schema upgrade (#963)
1 parent 1bc1c46 commit 189bcea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/firestore/src/local/simple_db.ts

+11
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,16 @@ 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. ' +
71+
'Close all tabs that access Firestore and reload this page to proceed.'
72+
)
73+
);
74+
};
75+
6576
request.onerror = (event: ErrorEvent) => {
6677
reject((event.target as IDBOpenDBRequest).error);
6778
};

0 commit comments

Comments
 (0)