From 7c9a5e71479292cf3dd766e796316bacfb89daee Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 31 Jan 2024 10:41:01 -0800 Subject: [PATCH] Make extra trailer behavior consistent with old code --- packages/grpc-js/src/server-call.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/grpc-js/src/server-call.ts b/packages/grpc-js/src/server-call.ts index 8fb1de2aa..edc38e983 100644 --- a/packages/grpc-js/src/server-call.ts +++ b/packages/grpc-js/src/server-call.ts @@ -56,14 +56,11 @@ export type ServerDuplexStream = ServerSurfaceCall & ObjectReadable & ObjectWritable & { 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 ( @@ -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; }