Skip to content

Commit

Permalink
Merge pull request #766 from murgatroid99/grpc-js_call_message_status…
Browse files Browse the repository at this point in the history
…_ordering

grpc-js: call-stream: Don't output messages after status
  • Loading branch information
murgatroid99 authored Mar 7, 2019
2 parents 669a6ef + 030f846 commit c3643e4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/grpc-js/src/call-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export class Http2CallStream extends Duplex implements Call {
}

private handleFilteredRead(message: Buffer) {
/* If we the call has already ended, we don't want to do anything with
* this message. Dropping it on the floor is correct behavior */
if (this.finalStatus !== null) {
return;
}
this.isReadFilterPending = false;
if (this.canPush) {
if (!this.push(message)) {
Expand All @@ -146,6 +151,11 @@ export class Http2CallStream extends Duplex implements Call {
}

private filterReceivedMessage(framedMessage: Buffer|null) {
/* If we the call has already ended, we don't want to do anything with
* this message. Dropping it on the floor is correct behavior */
if (this.finalStatus !== null) {
return;
}
if (framedMessage === null) {
if (this.canPush) {
this.push(null);
Expand Down Expand Up @@ -432,6 +442,12 @@ export class Http2CallStream extends Duplex implements Call {
}

_read(size: number) {
/* If we have already emitted a status, we should not emit any more
* messages and we should communicate that the stream has ended */
if (this.finalStatus !== null) {
this.push(null);
return;
}
this.canPush = true;
if (this.http2Stream === null) {
this.pendingRead = true;
Expand Down

0 comments on commit c3643e4

Please sign in to comment.