Skip to content

Commit

Permalink
fix(connection): fix promise chaining for openUri
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lantw44 committed Feb 22, 2021
1 parent 9323860 commit 6fe7301
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit 6fe7301

Please sign in to comment.