forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
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: nodejs#11761 PR-URL: nodejs#11762 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
- 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()); | ||
})); |