Merge pull request #766 from murgatroid99/grpc-js_call_message_status_ordering

grpc-js: call-stream: Don't output messages after status
This commit is contained in:
Michael Lumish 2019-03-07 15:47:18 -08:00 committed by GitHub
commit c3643e4acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -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)) {
@ -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);
@ -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;