mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
Revert "net: remove unnecessary process.nextTick()"
This reverts commit 571882c5a4.
Removing the process.nextTick() call can prevent the consumer
from being able to catch error events.
PR-URL: https://github.com/nodejs/node/pull/12854
Fixes: https://github.com/nodejs/node/issues/12841
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
committed by
James M Snell
parent
c7182b9d9c
commit
4fabcfc5a2
@@ -1036,7 +1036,10 @@ function lookupAndConnect(self, options) {
|
||||
// If host is an IP, skip performing a lookup
|
||||
var addressType = cares.isIP(host);
|
||||
if (addressType) {
|
||||
internalConnect(self, host, port, addressType, localAddress, localPort);
|
||||
nextTick(self[async_id_symbol], function() {
|
||||
if (self.connecting)
|
||||
internalConnect(self, host, port, addressType, localAddress, localPort);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +48,16 @@ const server = net
|
||||
{ port: server.address().port, host: server.address().address },
|
||||
common.mustCall(onconnected));
|
||||
const tcps = hooks.activitiesOfTypes('TCPWRAP');
|
||||
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
|
||||
assert.strictEqual(
|
||||
tcps.length, 2,
|
||||
'2 TCPWRAPs present when client is connecting');
|
||||
assert.strictEqual(
|
||||
tcpconnects.length, 1,
|
||||
'1 TCPCONNECTWRAP present when client is connecting');
|
||||
process.nextTick(() => {
|
||||
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
|
||||
assert.strictEqual(
|
||||
tcpconnects.length, 1,
|
||||
'1 TCPCONNECTWRAP present when client is connecting');
|
||||
});
|
||||
|
||||
tcp2 = tcps[1];
|
||||
assert.strictEqual(tcps.length, 2,
|
||||
'2 TCPWRAP present when client is connecting');
|
||||
|
||||
Reference in New Issue
Block a user