mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
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:
commit
13337aaa47
@ -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",
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user