Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc-js: Ensure ordering between status and final message #2316

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/grpc-js/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 5 additions & 1 deletion packages/grpc-js/src/subchannel-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand All @@ -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.
Expand Down