You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +03:00
Verbose logging to see what's up with indexeddb (#514)
In an attempt to see why our tests sometimes time out, add a load of logging to confirm exactly where it is happening.
This commit is contained in:
committed by
Luke Barnard
parent
06eea71a37
commit
d8f486fc0d
@@ -113,19 +113,41 @@ LocalIndexedDBStoreBackend.prototype = {
|
|||||||
*/
|
*/
|
||||||
connect: function() {
|
connect: function() {
|
||||||
if (this.db) {
|
if (this.db) {
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend.connect: already connected`,
|
||||||
|
);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend.connect: connecting`,
|
||||||
|
);
|
||||||
const req = this.indexedDB.open(this._dbName, VERSION);
|
const req = this.indexedDB.open(this._dbName, VERSION);
|
||||||
req.onupgradeneeded = (ev) => {
|
req.onupgradeneeded = (ev) => {
|
||||||
const db = ev.target.result;
|
const db = ev.target.result;
|
||||||
const oldVersion = ev.oldVersion;
|
const oldVersion = ev.oldVersion;
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend.connect: upgrading from ${oldVersion}`,
|
||||||
|
);
|
||||||
if (oldVersion < 1) { // The database did not previously exist.
|
if (oldVersion < 1) { // The database did not previously exist.
|
||||||
createDatabase(db);
|
createDatabase(db);
|
||||||
}
|
}
|
||||||
// Expand as needed.
|
// Expand as needed.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
req.onblocked = () => {
|
||||||
|
console.log(
|
||||||
|
`can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend.connect: awaiting connection`,
|
||||||
|
);
|
||||||
return promiseifyRequest(req).then((ev) => {
|
return promiseifyRequest(req).then((ev) => {
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend.connect: connected`,
|
||||||
|
);
|
||||||
this.db = ev.target.result;
|
this.db = ev.target.result;
|
||||||
|
|
||||||
// add a poorly-named listener for when deleteDatabase is called
|
// add a poorly-named listener for when deleteDatabase is called
|
||||||
@@ -147,6 +169,9 @@ LocalIndexedDBStoreBackend.prototype = {
|
|||||||
this._loadAccountData(),
|
this._loadAccountData(),
|
||||||
this._loadSyncData(),
|
this._loadSyncData(),
|
||||||
]).then(([accountData, syncData]) => {
|
]).then(([accountData, syncData]) => {
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend: loaded initial data`,
|
||||||
|
);
|
||||||
this._syncAccumulator.accumulate({
|
this._syncAccumulator.accumulate({
|
||||||
next_batch: syncData.nextBatch,
|
next_batch: syncData.nextBatch,
|
||||||
rooms: syncData.roomsData,
|
rooms: syncData.roomsData,
|
||||||
@@ -310,7 +335,13 @@ LocalIndexedDBStoreBackend.prototype = {
|
|||||||
* @return {Promise<Object[]>} A list of raw global account events.
|
* @return {Promise<Object[]>} A list of raw global account events.
|
||||||
*/
|
*/
|
||||||
_loadAccountData: function() {
|
_loadAccountData: function() {
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend: loading account data`,
|
||||||
|
);
|
||||||
return Promise.try(() => {
|
return Promise.try(() => {
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend: loaded account data`,
|
||||||
|
);
|
||||||
const txn = this.db.transaction(["accountData"], "readonly");
|
const txn = this.db.transaction(["accountData"], "readonly");
|
||||||
const store = txn.objectStore("accountData");
|
const store = txn.objectStore("accountData");
|
||||||
return selectQuery(store, undefined, (cursor) => {
|
return selectQuery(store, undefined, (cursor) => {
|
||||||
@@ -324,7 +355,13 @@ LocalIndexedDBStoreBackend.prototype = {
|
|||||||
* @return {Promise<Object>} An object with "roomsData" and "nextBatch" keys.
|
* @return {Promise<Object>} An object with "roomsData" and "nextBatch" keys.
|
||||||
*/
|
*/
|
||||||
_loadSyncData: function() {
|
_loadSyncData: function() {
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend: loaded sync data`,
|
||||||
|
);
|
||||||
return Promise.try(() => {
|
return Promise.try(() => {
|
||||||
|
console.log(
|
||||||
|
`LocalIndexedDBStoreBackend: loaded sync data`,
|
||||||
|
);
|
||||||
const txn = this.db.transaction(["sync"], "readonly");
|
const txn = this.db.transaction(["sync"], "readonly");
|
||||||
const store = txn.objectStore("sync");
|
const store = txn.objectStore("sync");
|
||||||
return selectQuery(store, undefined, (cursor) => {
|
return selectQuery(store, undefined, (cursor) => {
|
||||||
|
|||||||
@@ -115,12 +115,16 @@ utils.inherits(IndexedDBStore, MatrixInMemoryStore);
|
|||||||
*/
|
*/
|
||||||
IndexedDBStore.prototype.startup = function() {
|
IndexedDBStore.prototype.startup = function() {
|
||||||
if (this.startedUp) {
|
if (this.startedUp) {
|
||||||
|
console.log(`IndexedDBStore.startup: already started`);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`IndexedDBStore.startup: connecting to backend`);
|
||||||
return this.backend.connect().then(() => {
|
return this.backend.connect().then(() => {
|
||||||
|
console.log(`IndexedDBStore.startup: loading presence events`);
|
||||||
return this.backend.getUserPresenceEvents();
|
return this.backend.getUserPresenceEvents();
|
||||||
}).then((userPresenceEvents) => {
|
}).then((userPresenceEvents) => {
|
||||||
|
console.log(`IndexedDBStore.startup: processing presence events`);
|
||||||
userPresenceEvents.forEach(([userId, rawEvent]) => {
|
userPresenceEvents.forEach(([userId, rawEvent]) => {
|
||||||
const u = new User(userId);
|
const u = new User(userId);
|
||||||
if (rawEvent) {
|
if (rawEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user