From 9558845e6ed96087aca7f625080bdce21fbb601f Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 10 Jul 2017 17:14:52 +0100 Subject: [PATCH] Fix early return in MatrixClient.setGuestAccess (as well as a similar bug in the test suite) Turns out that `q.all(a, b)` === `q.all([a])`, rather than `q.all([a,b])`: it only waits for the *first* promise - which means that `client.setGuestAccess` would swallow any errors returned from the API. --- spec/integ/matrix-client-crypto.spec.js | 6 ++++-- src/client.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/integ/matrix-client-crypto.spec.js b/spec/integ/matrix-client-crypto.spec.js index 5ea3e9430..397ac7d65 100644 --- a/spec/integ/matrix-client-crypto.spec.js +++ b/spec/integ/matrix-client-crypto.spec.js @@ -426,8 +426,10 @@ describe("MatrixClient crypto", function() { expect(bobDeviceKeys.keys["curve25519:" + bobDeviceId]).toBeTruthy(); bobDeviceKeys.keys["curve25519:" + bobDeviceId] += "abc"; - return q.all(aliTestClient.client.downloadKeys([bobUserId]), - expectAliQueryKeys()); + return q.all([ + aliTestClient.client.downloadKeys([bobUserId]), + expectAliQueryKeys(), + ]); }) .then(function() { // should get an empty list diff --git a/src/client.js b/src/client.js index 85e6fa08f..36b574722 100644 --- a/src/client.js +++ b/src/client.js @@ -2153,7 +2153,7 @@ MatrixClient.prototype.setGuestAccess = function(roomId, opts) { }); } - return q.all(readPromise, writePromise); + return q.all([readPromise, writePromise]); }; // Registration/Login operations