mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user