Skip to content

Commit 238afde

Browse files
committed
Increase the timeout for clearing indexeddbs
Chrome seems to take ages (like, 1500ms regularly) to clear out the indexeddbs, and that's causing test timeouts. Bump the timeout to hack around it. Also: clear both dbs in parallel (can't hurt, right?) and improve diagnostics on the process.
1 parent cb4f57e commit 238afde

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

test/app-tests/loading.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,14 @@ describe('loading:', function () {
8282
// unmounting should have cleared the MatrixClientPeg
8383
expect(MatrixClientPeg.get()).toBe(null);
8484

85+
// chrome seems to take *ages* to delete the indexeddbs.
86+
this.timeout(10000);
87+
8588
// clear the indexeddbs so we can start from a clean slate next time.
86-
await test_utils.deleteIndexedDB('matrix-js-sdk:crypto');
87-
await test_utils.deleteIndexedDB('matrix-js-sdk:riot-web-sync');
89+
await Promise.all([
90+
test_utils.deleteIndexedDB('matrix-js-sdk:crypto'),
91+
test_utils.deleteIndexedDB('matrix-js-sdk:riot-web-sync'),
92+
]);
8893
console.log(`${Date.now()}: loading: afterEach complete`);
8994
});
9095

test/test-utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export function deleteIndexedDB(dbName) {
3434
return;
3535
}
3636

37-
console.log(`${Date.now()}: Removing indexeddb instance: ${dbName}`);
37+
const startTime = Date.now();
38+
console.log(`${startTime}: Removing indexeddb instance: ${dbName}`);
3839
const req = window.indexedDB.deleteDatabase(dbName);
3940

4041
req.onblocked = () => {
@@ -48,7 +49,8 @@ export function deleteIndexedDB(dbName) {
4849
};
4950

5051
req.onsuccess = () => {
51-
console.log(`${Date.now()}: Removed indexeddb instance: ${dbName}`);
52+
const now = Date.now();
53+
console.log(`${now}: Removed indexeddb instance: ${dbName} in ${now-startTime} ms`);
5254
resolve();
5355
};
5456
}).catch((e) => {

0 commit comments

Comments
 (0)