From bc1d758408ce67db8fbdb212d7677831eac55d9e Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 4 Jan 2011 11:25:36 -0800 Subject: [PATCH] net.js: Check that readWatcher exists before pause, resume --- lib/net.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/net.js b/lib/net.js index 24f2e4a5bb..832954aa3e 100644 --- a/lib/net.js +++ b/lib/net.js @@ -695,15 +695,17 @@ Stream.prototype.setTimeout = function(msecs) { Stream.prototype.pause = function() { - this._readWatcher.stop(); + if (this._readWatcher) this._readWatcher.stop(); }; Stream.prototype.resume = function() { if (this.fd === null) throw new Error('Cannot resume() closed Stream.'); - this._readWatcher.stop(); - this._readWatcher.set(this.fd, true, false); - this._readWatcher.start(); + if (this._readWatcher) { + this._readWatcher.stop(); + this._readWatcher.set(this.fd, true, false); + this._readWatcher.start(); + } }; Stream.prototype.destroySoon = function() {