diff --git a/lib/memjs/server.d.ts b/lib/memjs/server.d.ts index 53a41d6..f9c051a 100644 --- a/lib/memjs/server.d.ts +++ b/lib/memjs/server.d.ts @@ -26,7 +26,8 @@ export declare class Server extends events.EventEmitter { host: string; port: string | number | undefined; connected: boolean; - timeoutSet: boolean; + connectionTimeoutSet: boolean; + commandTimeoutId: NodeJS.Timeout | undefined; connectCallbacks: OnConnectCallback[]; responseCallbacks: { [seq: string]: OnResponseCallback; diff --git a/lib/memjs/server.d.ts.map b/lib/memjs/server.d.ts.map index 6128b8f..73dcbb6 100644 --- a/lib/memjs/server.d.ts.map +++ b/lib/memjs/server.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/memjs/server.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAKL,OAAO,EACR,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,aAAK,GAAG,GAAG,MAAM,CAAC;AAElB,MAAM,WAAW,iBAAiB;IAChC,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACtB;AAED,qBAAa,MAAO,SAAQ,MAAM,CAAC,YAAY;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB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E;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAC;IACnD,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,OAAO,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC;gBAG9B,IAAI,EAAE,MAAM,EAEZ,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC;IAqClC,SAAS,CAAC,IAAI,EAAE,iBAAiB;IAIjC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,kBAAkB;IAI7C,OAAO,CAAC,QAAQ,EAAE,OAAO;IAczB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe;IAIvC,KAAK,CAAC,GAAG,EAAE,KAAK;IAoBhB,QAAQ;IAKR,QAAQ;IAMR,cAAc,CAAC,OAAO,EAAE,MAAM;IAO9B,eAAe,CAAC,OAAO,EAAE,MAAM;IAyB/B,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB;IA+FzC,KAAK,CAAC,IAAI,EAAE,MAAM;IAclB,SAAS,CAAC,IAAI,EAAE,MAAM;IAMtB,KAAK;IAQL,QAAQ;IAIR,cAAc;CAGf"} \ No newline at end of file diff --git a/lib/memjs/server.js b/lib/memjs/server.js index 3663474..81aad12 100644 --- a/lib/memjs/server.js +++ b/lib/memjs/server.js @@ -16,7 +16,8 @@ class Server extends events_1.default.EventEmitter { this.host = host; this.port = port; this.connected = false; - this.timeoutSet = false; + this.connectionTimeoutSet = false; + this.commandTimeoutId = undefined; this.connectCallbacks = []; this.responseCallbacks = {}; this.requestTimeouts = []; @@ -69,7 +70,8 @@ class Server extends events_1.default.EventEmitter { // reset all states except host, port, options, username, password this.responseBuffer = Buffer.from([]); this.connected = false; - this.timeoutSet = false; + this.connectionTimeoutSet = false; + this.commandTimeoutId = undefined; this.connectCallbacks = []; this.responseCallbacks = {}; this.requestTimeouts = []; @@ -144,7 +146,7 @@ class Server extends events_1.default.EventEmitter { self.connected = true; // cancel connection timeout self._socket.setTimeout(0); - self.timeoutSet = false; + self.connectionTimeoutSet = false; // run actual request(s) go(self._socket); self.connectCallbacks.forEach(function (cb) { @@ -176,16 +178,20 @@ class Server extends events_1.default.EventEmitter { } self.connected = false; self.responseBuffer = Buffer.from([]); - if (self.timeoutSet) { + if (self.connectionTimeoutSet) { (_a = self._socket) === null || _a === void 0 ? void 0 : _a.setTimeout(0); - self.timeoutSet = false; + self.connectionTimeoutSet = false; + } + if (self.commandTimeoutId !== undefined) { + clearTimeout(self.commandTimeoutId); + self.commandTimeoutId = undefined; } self._socket = undefined; }); // setup connection timeout handler - self.timeoutSet = true; + self.connectionTimeoutSet = true; self._socket.setTimeout(self.options.conntimeout * 1000, function () { - self.timeoutSet = false; + self.connectionTimeoutSet = false; if (!self.connected) { this.end(); self._socket = undefined; @@ -210,11 +216,10 @@ class Server extends events_1.default.EventEmitter { this.sock(false, function (s) { s.write(blob); self.requestTimeouts.push(utils_1.timestamp() + deadline); - if (!self.timeoutSet) { - self.timeoutSet = true; - s.setTimeout(deadline, function () { - timeoutHandler(self, this); - }); + if (self.commandTimeoutId === undefined) { + self.commandTimeoutId = setTimeout(function () { + timeoutHandler(self, s); + }, deadline); } }); } @@ -244,7 +249,7 @@ exports.Server = Server; const timeoutHandler = function (server, sock) { if (server.requestTimeouts.length === 0) { // nothing active - server.timeoutSet = false; + server.commandTimeoutId = undefined; return; } // some requests outstanding, check if any have timed-out @@ -257,9 +262,9 @@ const timeoutHandler = function (server, sock) { else { // no timeout! Setup next one. const deadline = soonestTimeout - now; - sock.setTimeout(deadline, function () { + server.commandTimeoutId = setTimeout(function () { timeoutHandler(server, sock);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YnV0IHNlZW1zIGJhZCBvdmVyYWxsLiAqL1xuICAgICAgICB0eXBlb2YgdGhpcy5wb3J0ID09PSBcInN0cmluZ1wiXG4gICAgICAgICAgPyBwYXJzZUludCh0aGlzLnBvcnQsIDEwKVxuICAgICAgICAgIDogdGhpcy5wb3J0IHx8IDExMjExLFxuICAgICAgICB0aGlzLmhvc3QsXG4gICAgICAgIGZ1bmN0aW9uICh0aGlzOiBuZXQuU29ja2V0KSB7XG4gICAgICAgICAgLy8gU0FTTCBhdXRoZW50aWNhdGlvbiBoYW5kbGVyXG4gICAgICAgICAgc2VsZi5vbmNlKFwiYXV0aGVudGljYXRlZFwiLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5fc29ja2V0KSB7XG4gICAgICAgICAgICAgIGNvbnN0IHNvY2tldCA9IHNlbGYuX3NvY2tldDtcbiAgICAgICAgICAgICAgc2VsZi5jb25uZWN0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAvLyBjYW5jZWwgY29ubmVjdGlvbiB0aW1lb3V0XG4gICAgICAgICAgICAgIHNlbGYuX3NvY2tldC5zZXRUaW1lb3V0KDApO1xuICAgICAgICAgICAgICBzZWxmLnRpbWVvdXRTZXQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgLy8gcnVuIGFjdHVhbCByZXF1ZXN0KHMpXG4gICAgICAgICAgICAgIGdvKHNlbGYuX3NvY2tldCk7XG4gICAgICAgICAgICAgIHNlbGYuY29ubmVjdENhbGxiYWNrcy5mb3JFYWNoKGZ1bmN0aW9uIChjYikge1xuICAgICAgICAgICAgICAgIGNiKHNvY2tldCk7XG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBzZWxmLmNvbm5lY3RDYWxsYmFja3MgPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcblxuICAgICAgICAgIC8vIHNldHVwIHJlc3BvbnNlIGhhbmRsZXJcbiAgICAgICAgICB0aGlzLm9uKFwiZG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Y2tldDtcbiAgICAgICAgICAgICAgc2VsZi5jb25uZWN0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAvLyBjYW5jZWwgY29ubmVjdGlvbiB0aW1lb3V0XG4gICAgICAgICAgICAgIHNlbGYuX3NvY2tldC5zZXRUaW1lb3V0KDApO1xuICAgICAgICAgICAgICBzZWxmLmNvbm5lY3Rpb25UaW1lb3V0U2V0ID0gZmFsc2U7XG4gICAgICAgICAgICAgIC8vIHJ1biBhY3R1YWwgcmVxdWVzdChzKVxuICAgICAgICAgICAgICBnbyhzZWxmLl9zb2NrZXQpO1xuICAgICAgICAgICAgICBzZWxmLmNvbm5lY3RDYWxsYmFja3MuZm9yRWFjaChmdW5jdGlvbiAoY2IpIHtcbiAgICAgICAgICAgICAgICBjYihzb2NrZXQpO1xuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgc2VsZi5jb25uZWN0Q2FsbGJhY2tzID0gW107XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSk7XG5cbiAgICAgICAgICAvLyBzZXR1cCByZXNwb25zZSBoYW5kbGVyXG4gICAgICAgICAgdGhpcy5vbihcImRhdGFcIiwgZnVuY3Rpb24gKGRhdGFCdWYpIHtcbiAgICAgICAgICAgIHNlbGYucmVzcG9uc2VIYW5kbGVyKGRhdGFCdWYpO1xuICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgLy8ga2ljayBvZiBTQVNMIGlmIG5lZWRlZFxuICAgICAgICAgIGlmIChzZWxmLnVzZXJuYW1lICYmIHNlbGYucGFzc3dvcmQpIHtcbiAgICAgICAgICAgIHNlbGYubGlzdFNhc2woKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc2VsZi5lbWl0KFwiYXV0aGVudGljYXRlZFwiKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICk7XG5cbiAgICAgIC8vIHNldHVwIGVycm9yIGhhbmRsZXJcbiAgICAgIHNlbGYuX3NvY2tldC5vbihcImV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Ly8gbm9kZSBkb2Vzbid0IGxpa2UgdXMgc2V0dGluZyB1cCBsb3RzIG9mIHRpbWVycywgYW5kIHVzaW5nIGp1c3Qgb25lIGlzIG1vcmVcbi8vIGVmZmljaWVudCBhbnl3YXkuXG5jb25zdCB0aW1lb3V0SGFuZGxlciA9IGZ1bmN0aW9uIChzZXJ2ZXI6IFNlcnZlciwgc29jazogbmV0LlNvY2tldCkge1xuICBpZiAoc2VydmVyLnJlcXVlc3RUaW1lb3V0cy5sZW5ndGggPT09IDApIHtcbiAgICAvLyBub3RoaW5nIGFjdGl2ZVxuICAgIHNlcnZlci5jb21tYW5kVGltZW91dElkID0gdW5kZWZpbmVkO1xuICAgIHJldHVybjtcbiAgfVxuXG4gIC8vIHNvbWUgcmVxdWVzdHMgb3V0c3RhbmRpbmcsIGNoZWNrIGlmIGFueSBoYXZlIHRpbWVkLW91dFxuICBjb25zdCBub3cgPSB0aW1lc3RhbXAoKTtcbiAgY29uc3Qgc29vbmVzdFRpbWVvdXQgPSBzZXJ2ZXIucmVxdWVzdFRpbWVvdXRzWzBdO1xuXG4gIGlmIChzb29uZXN0VGltZW91dCA8PSBub3cpIHtcbiAgICAvLyB0aW1lb3V0IG9jY3VycmVkIVxuICAgIHNlcnZlci5lcnJvcihuZXcgRXJyb3IoXCJzb2NrZXQgdGltZWQgb3V0IHdhaXRpbmcgb24gcmVzcG9uc2UuXCIpKTtcbiAgfSBlbHNlIHtcbiAgICAvLyBubyB0aW1lb3V0ISBTZXR1cCBuZXh0IG9uZS5cbiAgICBjb25zdCBkZWFkbGluZSA9IHNvb25lc3RUaW1lb3V0IC0gbm93O1xuICAgIHNlcnZlci5jb21tYW5kVGltZW91dElkID0gc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICB0aW1lb3V0SGFuZGxlcihzZXJ2ZXIsIHNvY2spO1xuICAgIH0sIGRlYWRsaW5lKTtcbiAgfVxufTtcbiJdfQ== \ No newline at end of file diff --git a/src/memjs/server.ts b/src/memjs/server.ts index 5f7b830..de8ed43 100644 --- a/src/memjs/server.ts +++ b/src/memjs/server.ts @@ -37,7 +37,8 @@ export class Server extends events.EventEmitter { host: string; port: string | number | undefined; connected: boolean; - timeoutSet: boolean; + connectionTimeoutSet: boolean; + commandTimeoutId: NodeJS.Timeout | undefined; connectCallbacks: OnConnectCallback[]; responseCallbacks: { [seq: string]: OnResponseCallback }; requestTimeouts: number[]; @@ -61,7 +62,8 @@ export class Server extends events.EventEmitter { this.host = host; this.port = port; this.connected = false; - this.timeoutSet = false; + this.connectionTimeoutSet = false; + this.commandTimeoutId = undefined; this.connectCallbacks = []; this.responseCallbacks = {}; this.requestTimeouts = []; @@ -121,7 +123,8 @@ export class Server extends events.EventEmitter { // reset all states except host, port, options, username, password this.responseBuffer = Buffer.from([]); this.connected = false; - this.timeoutSet = false; + this.connectionTimeoutSet = false; + this.commandTimeoutId = undefined; this.connectCallbacks = []; this.responseCallbacks = {}; this.requestTimeouts = []; @@ -199,7 +202,7 @@ export class Server extends events.EventEmitter { self.connected = true; // cancel connection timeout self._socket.setTimeout(0); - self.timeoutSet = false; + self.connectionTimeoutSet = false; // run actual request(s) go(self._socket); self.connectCallbacks.forEach(function (cb) { @@ -234,19 +237,23 @@ export class Server extends events.EventEmitter { } self.connected = false; self.responseBuffer = Buffer.from([]); - if (self.timeoutSet) { + if (self.connectionTimeoutSet) { self._socket?.setTimeout(0); - self.timeoutSet = false; + self.connectionTimeoutSet = false; + } + if (self.commandTimeoutId !== undefined) { + clearTimeout(self.commandTimeoutId); + self.commandTimeoutId = undefined; } self._socket = undefined; }); // setup connection timeout handler - self.timeoutSet = true; + self.connectionTimeoutSet = true; self._socket.setTimeout( self.options.conntimeout * 1000, function (this: net.Socket) { - self.timeoutSet = false; + self.connectionTimeoutSet = false; if (!self.connected) { this.end(); self._socket = undefined; @@ -275,11 +282,10 @@ export class Server extends events.EventEmitter { this.sock(false, function (s) { s.write(blob); self.requestTimeouts.push(timestamp() + deadline); - if (!self.timeoutSet) { - self.timeoutSet = true; - s.setTimeout(deadline, function (this: net.Socket) { - timeoutHandler(self, this); - }); + if (self.commandTimeoutId === undefined) { + self.commandTimeoutId = setTimeout(function () { + timeoutHandler(self, s); + }, deadline); } }); } @@ -313,7 +319,7 @@ export class Server extends events.EventEmitter { const timeoutHandler = function (server: Server, sock: net.Socket) { if (server.requestTimeouts.length === 0) { // nothing active - server.timeoutSet = false; + server.commandTimeoutId = undefined; return; } @@ -327,8 +333,8 @@ const timeoutHandler = function (server: Server, sock: net.Socket) { } else { // no timeout! Setup next one. const deadline = soonestTimeout - now; - sock.setTimeout(deadline, function () { + server.commandTimeoutId = setTimeout(function () { timeoutHandler(server, sock); - }); + }, deadline); } };