Merge pull request #1186 from matrix-org/rav/startup_logging

Add some logging to track down flaky test
pull/21833/head
Richard van der Hoff 2017-07-05 16:29:03 +01:00 committed by GitHub
commit b52a6a693a
2 changed files with 14 additions and 8 deletions

View File

@ -419,6 +419,8 @@ export function logout() {
* listen for events while a session is logged in. * listen for events while a session is logged in.
*/ */
function startMatrixClient() { function startMatrixClient() {
console.log(`Lifecycle: Starting MatrixClient`);
// dispatch this before starting the matrix client: it's used // dispatch this before starting the matrix client: it's used
// to add listeners for the 'sync' event so otherwise we'd have // to add listeners for the 'sync' event so otherwise we'd have
// a race condition (and we need to dispatch synchronously for this // a race condition (and we need to dispatch synchronously for this

View File

@ -77,22 +77,26 @@ class MatrixClientPeg {
this._createClient(creds); this._createClient(creds);
} }
start() { async start() {
const opts = utils.deepCopy(this.opts); const opts = utils.deepCopy(this.opts);
// the react sdk doesn't work without this, so don't allow // the react sdk doesn't work without this, so don't allow
opts.pendingEventOrdering = "detached"; opts.pendingEventOrdering = "detached";
try {
let promise = this.matrixClient.store.startup(); let promise = this.matrixClient.store.startup();
console.log(`MatrixClientPeg: waiting for MatrixClient store to initialise`);
await promise;
} catch(err) {
// log any errors when starting up the database (if one exists) // log any errors when starting up the database (if one exists)
promise.catch((err) => {
console.error(`Error starting matrixclient store: ${err}`); console.error(`Error starting matrixclient store: ${err}`);
}); }
// regardless of errors, start the client. If we did error out, we'll // regardless of errors, start the client. If we did error out, we'll
// just end up doing a full initial /sync. // just end up doing a full initial /sync.
promise.finally(() => {
console.log(`MatrixClientPeg: really starting MatrixClient`);
this.get().startClient(opts); this.get().startClient(opts);
}); console.log(`MatrixClientPeg: MatrixClient started`);
} }
getCredentials(): MatrixClientCreds { getCredentials(): MatrixClientCreds {