Skip to content

Commit

Permalink
Merge pull request #2683 from murgatroid99/grpc-js_server_event_order
Browse files Browse the repository at this point in the history
grpc-js: Rearrange some function calls to revert event order changes
  • Loading branch information
murgatroid99 authored Mar 7, 2024
2 parents cb966df + 07ee52a commit 55b9852
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/grpc-js/src/server-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
}

_final(callback: Function): void {
callback(null);
this.call.sendStatus({
...this.pendingStatus,
metadata: this.pendingStatus.metadata ?? this.trailingMetadata,
});
callback(null);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -273,11 +273,11 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
}

_final(callback: Function): void {
callback(null);
this.call.sendStatus({
...this.pendingStatus,
metadata: this.pendingStatus.metadata ?? this.trailingMetadata,
});
callback(null);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
5 changes: 4 additions & 1 deletion packages/grpc-js/src/server-interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,6 @@ export class BaseServerInterceptingCall
if (this.checkCancelled()) {
return;
}
this.notifyOnCancel();

trace(
'Request to method ' +
Expand All @@ -869,8 +868,11 @@ export class BaseServerInterceptingCall
};

this.stream.sendTrailers(trailersToSend);
this.notifyOnCancel();
});
this.stream.end();
} else {
this.notifyOnCancel();
}
} else {
if (this.callEventTracker && !this.streamEnded) {
Expand All @@ -886,6 +888,7 @@ export class BaseServerInterceptingCall
...status.metadata?.toHttp2Headers(),
};
this.stream.respond(trailersToSend, { endStream: true });
this.notifyOnCancel();
}
}
startRead(): void {
Expand Down

0 comments on commit 55b9852

Please sign in to comment.