From 9f91995f4e6a54cf608644f3ae675377a01d3b56 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 15 Mar 2016 14:15:15 +0000 Subject: [PATCH] Fix tests by returning the original promise to avoid the extra trip around the event loop. --- lib/http-api.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/http-api.js b/lib/http-api.js index 2d9d574c8..675749250 100644 --- a/lib/http-api.js +++ b/lib/http-api.js @@ -271,14 +271,18 @@ module.exports.MatrixHttpApi.prototype = { if (!queryParams) { queryParams = {}; } queryParams.access_token = this.opts.accessToken; var self = this; - return this.request( + var request_promise = this.request( callback, method, path, queryParams, data, localTimeoutMs - ).catch(function(err) { + ); + request_promise.catch(function(err) { if (err.errcode == 'M_UNKNOWN_TOKEN') { self.event_emitter.emit("Session.logged_out"); } throw err; }); + // return the original promise, otherwise tests break due to it having to + // go around the event loop one more time to process the result of the request + return request_promise; }, /**