From b78db9d2225a391e23a0e6cefd2b85f919e708f1 Mon Sep 17 00:00:00 2001 From: Andrew Matheny Date: Wed, 1 Jun 2022 12:33:31 -0400 Subject: [PATCH 1/2] Propagate callEnd events --- packages/grpc-js/src/server-call.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/grpc-js/src/server-call.ts b/packages/grpc-js/src/server-call.ts index 315c9d9a..725199e3 100644 --- a/packages/grpc-js/src/server-call.ts +++ b/packages/grpc-js/src/server-call.ts @@ -726,6 +726,8 @@ export class Http2ServerCallStream< call.cancelled = true; call.emit('cancelled', reason); }); + + this.once('callEnd', (status) => call.emit('callEnd', status)); } setupReadable( From d846cf51272f2ed03c1dd8b845536fa7a901f396 Mon Sep 17 00:00:00 2001 From: Andrew Matheny Date: Wed, 1 Jun 2022 12:34:11 -0400 Subject: [PATCH 2/2] Expose http path in call --- packages/grpc-js/src/server-call.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/grpc-js/src/server-call.ts b/packages/grpc-js/src/server-call.ts index 725199e3..1f7f3eb0 100644 --- a/packages/grpc-js/src/server-call.ts +++ b/packages/grpc-js/src/server-call.ts @@ -80,6 +80,7 @@ export type ServerSurfaceCall = { getPeer(): string; sendMetadata(responseMetadata: Metadata): void; getDeadline(): Deadline; + getPath(): string; } & EventEmitter; export type ServerUnaryCall = ServerSurfaceCall & { @@ -127,6 +128,10 @@ export class ServerUnaryCallImpl getDeadline(): Deadline { return this.call.getDeadline(); } + + getPath(): string { + return this.call.getPath(); + } } export class ServerReadableStreamImpl @@ -165,6 +170,10 @@ export class ServerReadableStreamImpl getDeadline(): Deadline { return this.call.getDeadline(); } + + getPath(): string { + return this.call.getPath(); + } } export class ServerWritableStreamImpl @@ -202,6 +211,10 @@ export class ServerWritableStreamImpl return this.call.getDeadline(); } + getPath(): string { + return this.call.getPath(); + } + _write( chunk: ResponseType, encoding: string, @@ -279,6 +292,10 @@ export class ServerDuplexStreamImpl return this.call.getDeadline(); } + getPath(): string { + return this.call.getPath(); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any end(metadata?: any) { if (metadata) { @@ -901,6 +918,10 @@ export class Http2ServerCallStream< getDeadline(): Deadline { return this.deadline; } + + getPath(): string { + return this.handler.path; + } } /* eslint-disable @typescript-eslint/no-explicit-any */