From 526d852565e88349a1ba3aa66d30d0548e95f085 Mon Sep 17 00:00:00 2001 From: Ben Taber Date: Mon, 24 Dec 2012 18:35:52 -0700 Subject: [PATCH] net: allow socket end before connect Fix a bug where calling .end() on a socket without calling .connect() first throws a TypeError: TypeError: Cannot read property 'shutdown' of undefined at Socket.onSocketFinish (net.js:194:20) at Socket.EventEmitter.emit (events.js:91:17) at Socket.Writable.end (_stream_writable.js:281:10) at Socket.end (net.js:352:31) Fixes #4463. --- lib/net.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/net.js b/lib/net.js index 10c76ff..e0bbef6 100644 --- a/lib/net.js +++ b/lib/net.js @@ -191,7 +191,7 @@ function onSocketFinish() { debug('oSF: not ended, call shutdown()'); // otherwise, just shutdown, or destroy() if not possible - if (!this._handle.shutdown) + if (!this._handle || !this._handle.shutdown) return this.destroy(); var shutdownReq = this._handle.shutdown(); -- 2.7.4