Skip to content

Commit

Permalink
Make extra trailer behavior consistent with old code
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Jan 31, 2024
1 parent f52d142 commit 7c9a5e7
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions packages/grpc-js/src/server-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,11 @@ export type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall &
ObjectReadable<RequestType> &
ObjectWritable<ResponseType> & { end: (metadata?: Metadata) => void };

export function serverErrorToStatus(error: ServerErrorResponse | ServerStatusResponse, extraTrailers?: Metadata | undefined): PartialStatusObject {
export function serverErrorToStatus(error: ServerErrorResponse | ServerStatusResponse, overrideTrailers?: Metadata | undefined): PartialStatusObject {
const status: PartialStatusObject = {
code: Status.UNKNOWN,
details: 'message' in error ? error.message : 'Unknown Error',
metadata:
'metadata' in error && error.metadata !== undefined
? error.metadata
: null,
metadata: overrideTrailers ?? error.metadata ?? null
};

if (
Expand All @@ -77,14 +74,6 @@ export function serverErrorToStatus(error: ServerErrorResponse | ServerStatusRes
status.details = error.details!;
}
}

if (extraTrailers) {
if (status.metadata) {
status.metadata.merge(extraTrailers);
} else {
status.metadata = extraTrailers;
}
}
return status;
}

Expand Down

0 comments on commit 7c9a5e7

Please sign in to comment.