Skip to content

Commit

Permalink
fix(grpc): schedule messages forwarding after the current event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 27, 2024
1 parent e411d80 commit 96e3e79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ export function GrpcStreamMethod(

// Drain buffer if "drainBuffer" method is available
if (observable && observable.drainBuffer) {
process.nextTick(() => {
observable.drainBuffer();
});
observable.drainBuffer();
}
return result;
};
Expand Down
6 changes: 4 additions & 2 deletions packages/microservices/server/server-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,10 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
hasDrained = true;

// Replay buffered values to the new subscriber
replayBuffer.subscribe(subject);
replayBuffer.complete();
setImmediate(() => {
replayBuffer.subscribe(subject);
replayBuffer.complete();
});
}

return {
Expand Down

0 comments on commit 96e3e79

Please sign in to comment.