Skip to content

Commit

Permalink
Check whether topChannel is destroyed too
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed Nov 13, 2015
1 parent 7a2bea9 commit 9954fa5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var TypedError = require('error/typed');
var ChannelDestroyedError = TypedError({
type: 'ringpop.client.channel-destroyed',
message: 'Channel is already destroyed',
endpoint: null
endpoint: null,
channelType: null
});

function RingpopClient(subChannel) {
Expand Down Expand Up @@ -96,7 +97,18 @@ RingpopClient.prototype._request = function _request(opts, endpoint, head, body,
if (this.subChannel.destroyed) {
process.nextTick(function onTick() {
callback(ChannelDestroyedError({
endpoint: endpoint
endpoint: endpoint,
channelType: 'subChannel'
}));
});
return;
}

if (this.subChannel.topChannel.destroyed) {
process.nextTick(function onTick() {
callback(ChannelDestroyedError({
endpoint: endpoint,
channelType: 'topChannel'
}));
});
return;
Expand Down

0 comments on commit 9954fa5

Please sign in to comment.