Skip to content

Commit

Permalink
fix(connection): set $hasHandler on promises returned from openSet()
Browse files Browse the repository at this point in the history
Re: #5229
  • Loading branch information
vkarpov15 committed May 12, 2017
1 parent 1f16739 commit d5da9ca
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ Connection.prototype.open = function() {
});
});

// Monkey-patch `.then()` so if the promise is handled, we don't emit an
// `error` event.
var _then = promise.then;
promise.then = function(resolve, reject) {
promise.$hasHandler = true;
Expand Down Expand Up @@ -584,6 +586,15 @@ Connection.prototype.openSet = function(uris, database, options, callback) {
resolve();
});
});

// Monkey-patch `.then()` so if the promise is handled, we don't emit an
// `error` event.
var _then = promise.then;
promise.then = function(resolve, reject) {
promise.$hasHandler = true;
return _then.call(promise, resolve, reject);
};

return promise;
};

Expand Down

0 comments on commit d5da9ca

Please sign in to comment.