mirror of https://github.com/grpc/grpc-node.git
grpc-js: Make calls use the min of parent and own deadline when both are provided
This commit is contained in:
parent
33691e8490
commit
c050f97534
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/grpc-js",
|
"name": "@grpc/grpc-js",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"description": "gRPC Library for Node - pure JS implementation",
|
"description": "gRPC Library for Node - pure JS implementation",
|
||||||
"homepage": "https://grpc.io/",
|
"homepage": "https://grpc.io/",
|
||||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||||
|
|
|
@ -630,7 +630,11 @@ export class Http2CallStream implements Call {
|
||||||
|
|
||||||
getDeadline(): Deadline {
|
getDeadline(): Deadline {
|
||||||
if (this.options.parentCall && this.options.flags & Propagate.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 {
|
} else {
|
||||||
return this.options.deadline;
|
return this.options.deadline;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue