Skip to content

Commit

Permalink
Merge pull request #13367 from nestjs/revert-13328-fix/redundant-emit…
Browse files Browse the repository at this point in the history
…-code

Revert "fix(microservices): fix redundant code to emit error"
  • Loading branch information
kamilmysliwiec authored Mar 27, 2024
2 parents f29f932 + f416f5a commit 872ab40
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/microservices/server/server-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
const handler = methodHandler(call.request, call.metadata, call);
const result$ = this.transformToObservable(await handler);

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

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

0 comments on commit 872ab40

Please sign in to comment.