Merge pull request #2316 from murgatroid99/grpc-js_push_order_fix

grpc-js: Ensure ordering between status and final message
This commit is contained in:
Michael Lumish 2023-01-09 13:19:35 -08:00 committed by GitHub
commit 13337aaa47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "1.8.1",
"version": "1.8.2",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

View File

@ -87,6 +87,7 @@ export class Http2SubchannelCall implements SubchannelCall {
private decoder = new StreamDecoder();
private isReadFilterPending = false;
private isPushPending = false;
private canPush = false;
/**
* Indicates that an 'end' event has come from the http2 stream, so there
@ -360,7 +361,8 @@ export class Http2SubchannelCall implements SubchannelCall {
this.finalStatus.code !== Status.OK ||
(this.readsClosed &&
this.unpushedReadMessages.length === 0 &&
!this.isReadFilterPending)
!this.isReadFilterPending &&
!this.isPushPending)
) {
this.outputStatus();
}
@ -373,7 +375,9 @@ export class Http2SubchannelCall implements SubchannelCall {
(message instanceof Buffer ? message.length : null)
);
this.canPush = false;
this.isPushPending = true;
process.nextTick(() => {
this.isPushPending = false;
/* 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.