Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
call callback of close even if server.close throws error
Browse files Browse the repository at this point in the history
  • Loading branch information
dkl-ppi committed Mar 13, 2015
1 parent 14171e7 commit 7c0e69b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ Agent.prototype = {
this._bayeux.close();
}
if (this._server) {
this._server.close(cb);
try {
this._server.close(cb);
} catch (e) {
cb();
}
}
}.bind(this));
}
Expand Down
14 changes: 13 additions & 1 deletion test/agent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,5 +472,17 @@ buster.testCase("buster-ci-agent", {
cb3();
assert.calledOnce(callback);
}
}
},

"calls callback of close even if server.close throws":
function () {

this.server.close.throws(new Error("Not running"));
this.agent = new Agent({});
var callback = this.stub();

this.agent.close(callback);

assert.calledOnce(callback);
}
});

0 comments on commit 7c0e69b

Please sign in to comment.