Skip to content

Commit

Permalink
client: don't call callbacks if close() is called (#258)
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 authored and johanbrandhorst committed Oct 21, 2018
1 parent ec6a6a9 commit 2974dfa
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 2974dfa

Please sign in to comment.