mirror of https://github.com/grpc/grpc-node.git
grpc-js: End calls faster if the deadline has already passed
This commit is contained in:
parent
2e3f9ac509
commit
21da990cb0
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/grpc-js",
|
"name": "@grpc/grpc-js",
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"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",
|
||||||
|
|
|
@ -56,10 +56,14 @@ export class DeadlineFilter extends BaseFilter implements Filter {
|
||||||
}
|
}
|
||||||
const now: number = new Date().getTime();
|
const now: number = new Date().getTime();
|
||||||
let timeout = this.deadline - now;
|
let timeout = this.deadline - now;
|
||||||
if (timeout < 0) {
|
if (timeout <= 0) {
|
||||||
timeout = 0;
|
process.nextTick(() => {
|
||||||
}
|
callStream.cancelWithStatus(
|
||||||
if (this.deadline !== Infinity) {
|
Status.DEADLINE_EXCEEDED,
|
||||||
|
'Deadline exceeded'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else if (this.deadline !== Infinity) {
|
||||||
this.timer = setTimeout(() => {
|
this.timer = setTimeout(() => {
|
||||||
callStream.cancelWithStatus(
|
callStream.cancelWithStatus(
|
||||||
Status.DEADLINE_EXCEEDED,
|
Status.DEADLINE_EXCEEDED,
|
||||||
|
|
Loading…
Reference in New Issue