-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: allow missing callback for Socket.connect
Arguments of Socket.prototype.connect should be also normalized, causing error when called without callback. Changed Socket.prototype.connect's code same as net.connect and added test. Fixes: #11761 PR-URL: #11762 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
- Loading branch information
1 parent
52f0092
commit 1dff218
Showing
2 changed files
with
29 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test ensures that socket.connect can be called without callback | ||
// which is optional. | ||
|
||
const net = require('net'); | ||
|
||
const server = net.createServer(common.mustCall(function(conn) { | ||
conn.end(); | ||
server.close(); | ||
})).listen(0, common.mustCall(function() { | ||
const client = new net.Socket(); | ||
|
||
client.on('connect', common.mustCall(function() { | ||
client.end(); | ||
})); | ||
|
||
client.connect(server.address()); | ||
})); |