Skip to content

Commit

Permalink
Merge pull request #13328 from youngkiu/fix/redundant-emit-code
Browse files Browse the repository at this point in the history
fix(microservices): fix redundant code to emit error
  • Loading branch information
kamilmysliwiec authored Mar 17, 2024
2 parents 2ec602e + 44bd97e commit 1bf2dc4
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions packages/microservices/server/server-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,7 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
const handler = methodHandler(call.request, call.metadata, call);
const result$ = this.transformToObservable(await handler);

try {
await this.writeObservableToGrpc(result$, call);
} catch (err) {
call.emit('error', err);
return;
}
await this.writeObservableToGrpc(result$, call);
};
}

Expand Down Expand Up @@ -387,12 +382,7 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
const handler = methodHandler(req.asObservable(), call.metadata, call);
const res = this.transformToObservable(await handler);
if (isResponseStream) {
try {
await this.writeObservableToGrpc(res, call);
} catch (err) {
call.emit('error', err);
return;
}
await this.writeObservableToGrpc(res, call);
} else {
const response = await lastValueFrom(
res.pipe(
Expand Down

0 comments on commit 1bf2dc4

Please sign in to comment.