From ed5b3ac1cda7c11c1b85ab6db60aad6884e89c25 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Thu, 21 May 2020 11:41:44 -0700 Subject: [PATCH] grpc-js: Don't push messages after ending a call --- packages/grpc-js/src/call-stream.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/grpc-js/src/call-stream.ts b/packages/grpc-js/src/call-stream.ts index fcfa8af19..041f9651c 100644 --- a/packages/grpc-js/src/call-stream.ts +++ b/packages/grpc-js/src/call-stream.ts @@ -289,6 +289,13 @@ export class Http2CallStream implements Call { ); this.canPush = false; process.nextTick(() => { + /* If we have already output the status any later messages should be + * ignored, and can cause out-of-order operation errors higher up in the + * stack. Checking as late as possible here to avoid any race conditions. + */ + if (this.statusOutput) { + return; + } this.listener?.onReceiveMessage(message); this.maybeOutputStatus(); });