Comparing version 1.4.9-0 to 1.4.9-1
@@ -705,2 +705,12 @@ /* | ||
/** | ||
* @api private | ||
*/ | ||
Client.prototype.clearConnectionTimeoutHandler = function () { | ||
if (this.connectionTimeoutHandler) { | ||
clearTimeout(this.connectionTimeoutHandler) | ||
delete this.connectionTimeoutHandler | ||
} | ||
} | ||
/** | ||
* Properly setup a stream event handlers. | ||
@@ -717,10 +727,9 @@ * | ||
if (this.connectionTimeoutHandler) { | ||
clearTimeout(this.connectionTimeoutHandler) | ||
delete this.connectionTimeoutHandler | ||
} | ||
if (this.options.timeout) { | ||
// tls upgrade will re-bind the handlers here, so if we have a timer we are going to ignore it | ||
if (this.options.timeout && !this.connectionTimeoutHandler) { | ||
this.connectionTimeoutHandler = setTimeout(() => { | ||
stream.destroy(new NatsError(CONN_TIMEOUT_MSG, CONN_TIMEOUT)) | ||
if (this.stream) { | ||
// this fires on the current stream | ||
this.stream.destroy(new NatsError(CONN_TIMEOUT_MSG, CONN_TIMEOUT)) | ||
} | ||
}, this.options.timeout) | ||
@@ -975,2 +984,3 @@ } | ||
this.stream.destroy() | ||
this.clearConnectionTimeoutHandler() | ||
this.stream = null | ||
@@ -1228,9 +1238,10 @@ } | ||
// add the first callback to a ping | ||
this.pongs.unshift(() => { | ||
this.pongs.unshift((err) => { | ||
if (err) { | ||
// failed the connection | ||
return | ||
} | ||
// this gets called when the first pong is received by the connection | ||
// if we have a connection timeout timer, remove it | ||
if (this.connectionTimeoutHandler) { | ||
clearTimeout(this.connectionTimeoutHandler) | ||
delete this.connectionTimeoutHandler | ||
} | ||
this.clearConnectionTimeoutHandler() | ||
// send any subscriptions, and strip pending | ||
@@ -1237,0 +1248,0 @@ this.sendSubscriptions() |
{ | ||
"name": "nats", | ||
"version": "1.4.9-0", | ||
"version": "1.4.9-1", | ||
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
114506
2440