mirror of https://github.com/grpc/grpc-node.git
Make extra trailer behavior consistent with old code
This commit is contained in:
parent
f52d1429fb
commit
7c9a5e7147
|
@ -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 (
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue