From 6fe73016c982c8029bf6f21d50a9cd0843eeda39 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Mon, 22 Feb 2021 18:07:25 +0800 Subject: [PATCH] fix(connection): fix promise chaining for openUri When a user calls openUri and attaches more than one callback to its return value with 'then' method, it should be able to pass the result of the first callback to the second one. Currently, openUri always pass 'undefined' to the second callback, making it behave differently from a regular promise. This is unlikely to be an expected behaviour. To fix it, modify openUri to propagate the return value of the user-provided callback to the 'then' method of the promise. --- lib/connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/connection.js b/lib/connection.js index 83ff8f8c9a0..178bfda8f5a 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -858,7 +858,7 @@ Connection.prototype.openUri = function(uri, options, callback) { this.then = function(resolve, reject) { return this.$initialConnection.then(() => { if (typeof resolve === 'function') { - resolve(_this); + return resolve(_this); } }, reject); };