Skip to content

Commit

Permalink
grpc-js: Make calls use the min of parent and own deadline when both …
Browse files Browse the repository at this point in the history
…are provided
  • Loading branch information
murgatroid99 committed Nov 18, 2020
1 parent 33691e8 commit c050f97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 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",
Expand Down
6 changes: 5 additions & 1 deletion packages/grpc-js/src/call-stream.ts
Expand Up @@ -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;
}
Expand Down

0 comments on commit c050f97

Please sign in to comment.