Skip to content

Commit

Permalink
Merge pull request #1633 from murgatroid99/grpc-js_deadline_propagati…
Browse files Browse the repository at this point in the history
…on_min_fix

grpc-js: Make calls use the min of parent and own deadline when both are provided
  • Loading branch information
murgatroid99 committed Nov 18, 2020
2 parents 33691e8 + c050f97 commit ebe377e
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 ebe377e

Please sign in to comment.