Skip to content

Commit aa84ea9

Browse files
authored
Update failureProcess.ts #998
#998
1 parent 02425fe commit aa84ea9

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

packages/pinus-rpc/lib/rpc-client/failureProcess.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ let failover = function (this: any, code: number, tracer: {servers: object}, ser
7272
self.dispatch.call(self, tracer, servers[0], msg, opts, cb);
7373
};
7474

75-
let __tmpTracer = {}
7675

7776
/**
7877
* Failsafe rpc failure process.
@@ -90,12 +89,9 @@ let failsafe = function (this: any, code: number, tracer: {[key: string]: any},
9089
let self = this;
9190
let retryTimes = opts.retryTimes || constants.DEFAULT_PARAM.FAILSAFE_RETRIES;
9291
let retryConnectTime = opts.retryConnectTime || constants.DEFAULT_PARAM.FAILSAFE_CONNECT_TIME;
93-
if (!tracer) {
94-
tracer = __tmpTracer;
95-
}
96-
if (!tracer.retryTimes) {
92+
if (tracer && !tracer.retryTimes) {
9793
tracer.retryTimes = 1;
98-
} else {
94+
} else if (tracer) {
9995
tracer.retryTimes += 1;
10096
}
10197
switch (code) {
@@ -104,7 +100,7 @@ let failsafe = function (this: any, code: number, tracer: {[key: string]: any},
104100
cb(new Error('rpc client is not started or cannot find remote server.'));
105101
break;
106102
case constants.RPC_ERROR.FAIL_CONNECT_SERVER:
107-
if (tracer.retryTimes <= retryTimes) {
103+
if (tracer && tracer.retryTimes <= retryTimes) {
108104
setTimeout(function () {
109105
self.connect(tracer, serverId, cb);
110106
}, retryConnectTime * tracer.retryTimes);
@@ -114,7 +110,7 @@ let failsafe = function (this: any, code: number, tracer: {[key: string]: any},
114110
break;
115111
case constants.RPC_ERROR.FAIL_FIND_MAILBOX:
116112
case constants.RPC_ERROR.FAIL_SEND_MESSAGE:
117-
if (tracer.retryTimes <= retryTimes) {
113+
if (tracer && tracer.retryTimes <= retryTimes) {
118114
setTimeout(function () {
119115
self.dispatch.call(self, tracer, serverId, msg, opts, cb);
120116
}, retryConnectTime * tracer.retryTimes);

0 commit comments

Comments
 (0)