diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/net.js b/lib/net.js index bfafb915379..ba67c3d2efa 100644 --- a/lib/net.js +++ b/lib/net.js @@ -396,13 +396,15 @@ Socket.prototype.setTimeout = function(msecs, callback) { Socket.prototype._onTimeout = function() { - // `.prevWriteQueueSize` !== `.updateWriteQueueSize()` means there is - // an active write in progress, so we suppress the timeout. - const prevWriteQueueSize = this._handle.writeQueueSize; - if (prevWriteQueueSize > 0 && - prevWriteQueueSize !== this._handle.updateWriteQueueSize()) { - this._unrefTimer(); - return; + if (this._handle) { + // `.prevWriteQueueSize` !== `.updateWriteQueueSize()` means there is + // an active write in progress, so we suppress the timeout. + const prevWriteQueueSize = this._handle.writeQueueSize; + if (prevWriteQueueSize > 0 && + prevWriteQueueSize !== this._handle.updateWriteQueueSize()) { + this._unrefTimer(); + return; + } } debug('_onTimeout'); this.emit('timeout'); |