You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linux stream 6.3.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 21 Jun 2023 20:46:20 +0000 x86_64 GNU/Linux
Subsystem
net
What steps will reproduce the bug?
Pick some unused port (so that connect will fail) and repeatedly attempt to connect using "localhost" hostname:
setInterval(()=>{conststream=net.createConnection(1234/* GARBAGE PORT */,'localhost');stream.on('error',()=>void0/* ECONNREFUSED */);},1000);
The number of open file descriptors will continue to climb with each attempt. Switching from 'localhost' -> '127.0.0.1' and all opened fd's are closed after connection failure.
From strace, we see the socket(...) syscalls for AF_INET6 (::1) and AF_INET (127.0.0,1), but only the AF_INET6 related descriptor is closed after connection failure.
Issue is resolved on more recent main branch 5da84a6 but I didn't see any commits that explicitly address this (I would be curious to see this if I missed it).
My naive guess would be that:
afterConnect seems to destroy/close failed out fd's.
But I'm sure its not so simple. I'll poke around but if any net.js experts around here would be generous enough to offer an explanation I'd be grateful.
Cheers!
The text was updated successfully, but these errors were encountered:
Version
v20.3.1
Platform
Linux stream 6.3.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 21 Jun 2023 20:46:20 +0000 x86_64 GNU/Linux
Subsystem
net
What steps will reproduce the bug?
Pick some unused port (so that connect will fail) and repeatedly attempt to connect using "localhost" hostname:
The number of open file descriptors will continue to climb with each attempt. Switching from
'localhost' -> '127.0.0.1'
and all opened fd's are closed after connection failure.From strace, we see the
socket(...)
syscalls for AF_INET6 (::1
) and AF_INET (127.0.0,1
), but only the AF_INET6 related descriptor is closed after connection failure.lsof -p
will show a similar result, with climbing file descriptors.How often does it reproduce? Is there a required condition?
See above.
What is the expected behavior? Why is that the expected behavior?
I'd expected unused sockfd's to be closed.
What do you see instead?
See above. For example that logs the
lsof
count, you should be able to use:Additional information
Issue is resolved on more recent
main
branch 5da84a6 but I didn't see any commits that explicitly address this (I would be curious to see this if I missed it).My naive guess would be that:
afterConnect
seems to destroy/close failed out fd's.node/lib/net.js
Lines 1569 to 1584 in 9869bdc
but
afterConnectMultiple
doesn't:node/lib/net.js
Lines 1602 to 1622 in 9869bdc
But I'm sure its not so simple. I'll poke around but if any net.js experts around here would be generous enough to offer an explanation I'd be grateful.
Cheers!
The text was updated successfully, but these errors were encountered: