Skip to content

Commit

Permalink
client: don't call callbacks if close() is called
Browse files Browse the repository at this point in the history
- ts-protoc-gen clears out the callbacks anyways
- Fixes #257
  • Loading branch information
virtuald committed Oct 20, 2018
1 parent 1a0523f commit fa7bd30
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ts/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class GrpcClient<TRequest extends ProtobufMessage, TResponse extends ProtobufMes

this.onEndCallbacks.forEach(callback => {
detach(() => {
if (this.closed) return;
callback(code, message, trailers);
});
});
Expand All @@ -230,6 +231,7 @@ class GrpcClient<TRequest extends ProtobufMessage, TResponse extends ProtobufMes
this.completed = true;
this.onEndCallbacks.forEach(callback => {
detach(() => {
if (this.closed) return;
callback(code, msg, trailers);
});
});
Expand All @@ -240,6 +242,7 @@ class GrpcClient<TRequest extends ProtobufMessage, TResponse extends ProtobufMes
if (this.completed || this.closed) return;
this.onMessageCallbacks.forEach(callback => {
detach(() => {
if (this.closed) return;
callback(res);
});
});
Expand Down

0 comments on commit fa7bd30

Please sign in to comment.