From c050f97534b3332fc0a4818e20415cdffaaaf60e Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 18 Nov 2020 13:08:06 -0800 Subject: [PATCH] grpc-js: Make calls use the min of parent and own deadline when both are provided --- packages/grpc-js/package.json | 2 +- packages/grpc-js/src/call-stream.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/grpc-js/package.json b/packages/grpc-js/package.json index 0e445377c..22142dcdd 100644 --- a/packages/grpc-js/package.json +++ b/packages/grpc-js/package.json @@ -1,6 +1,6 @@ { "name": "@grpc/grpc-js", - "version": "1.2.0", + "version": "1.2.1", "description": "gRPC Library for Node - pure JS implementation", "homepage": "https://grpc.io/", "repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", diff --git a/packages/grpc-js/src/call-stream.ts b/packages/grpc-js/src/call-stream.ts index 32b851654..91e24ea55 100644 --- a/packages/grpc-js/src/call-stream.ts +++ b/packages/grpc-js/src/call-stream.ts @@ -630,7 +630,11 @@ export class Http2CallStream implements Call { getDeadline(): Deadline { if (this.options.parentCall && this.options.flags & Propagate.DEADLINE) { - return this.options.parentCall.getDeadline(); + const parentDeadline = this.options.parentCall.getDeadline(); + const selfDeadline = this.options.deadline; + const parentDeadlineMsecs = parentDeadline instanceof Date ? parentDeadline.getTime() : parentDeadline; + const selfDeadlineMsecs = selfDeadline instanceof Date ? selfDeadline.getTime() : selfDeadline; + return Math.min(parentDeadlineMsecs, selfDeadlineMsecs); } else { return this.options.deadline; }