net: allow socket end before connect
authorBen Taber <ben.taber@gmail.com>
Tue, 25 Dec 2012 01:35:52 +0000 (18:35 -0700)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 25 Dec 2012 21:18:56 +0000 (22:18 +0100)
commit526d852565e88349a1ba3aa66d30d0548e95f085
tree375ed9ba9e828ddeca27e7dd9a2694f4dcea1fe4
parent6ecb0cd65d2f818a35adb80d23261555b63528ca
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