Skip to content

Commit

Permalink
fix(link-deatch): removeListener upon detach
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Jun 16, 2015
1 parent 7a81744 commit 05f1413
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,14 @@ Link.prototype.attach = function() {
Link.prototype.detach = function() {
var self = this;
var detachPromise = new Promise(function(resolve, reject) {
var onError = function(err) { reject(err); };
self.once(Link.ErrorReceived, onError);
self.once(Link.Detached, function(info) {
self.removeListener(Link.ErrorReceived, onError);
if (!!info.error) return reject(info.error);
if (!info.closed) return reject('link not closed');
resolve();
});

self.once(Link.ErrorReceived, function(err) {
reject(err);
});
});

this.linkSM.sendDetach();
Expand Down
2 changes: 1 addition & 1 deletion lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Session.prototype.addWindow = function(windowSize, flowOptions) {
};

Session.prototype.detachLink = function(link) {
link.detach();
return link.detach();
};

Session.prototype.end = function() {
Expand Down

0 comments on commit 05f1413

Please sign in to comment.