fix(microservices): cleanup unary call on unsubscribe

This commit is contained in:
szilveszterandras
2022-09-16 19:21:38 +03:00
parent 7db5638d3f
commit 269ffa3d62
2 changed files with 57 additions and 2 deletions

View File

@@ -241,13 +241,19 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
});
}
return new Observable(observer => {
client[methodName](...args, (error: any, data: any) => {
const call = client[methodName](...args, (error: any, data: any) => {
if (error) {
return observer.error(this.serializeError(error));
}
observer.next(data);
observer.complete();
});
return () => {
if (!call.finished) {
call.cancel();
}
};
});
};
}