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
{{ message }}
Repository navigation
Flaky: the tcp and udp port check test fails under load #154
tests/portCheck.test.ts > isPortFree > checks tcp and udp separately failed once in about fifteen npm test runs here today, during the work on #148. It passed twelve times in a row when run on its own afterwards, and eight more full runs were green, so it only shows up alongside the other files.
What the run printed:
× checks tcp and udp separately 14ms
FAIL tests/portCheck.test.ts > isPortFree > checks tcp and udp separately
14 ms is far too quick for the loop to have gone through its 20 attempts, so it is probably not the "every bound udp port also read as taken on tcp" throw at the end. More likely one of the test's own createSocket('udp4') / sock.bind(0, ...) calls failed and the socket emitted error with no handler on it, which vitest then reports against whichever test is running. The two tests above it bind without an error handler too.
Worth doing:
add an error handler to each socket and server the test creates, so a failed bind fails with its own message instead of an unhandled event
then run the suite in a loop to see whether the failure is really a bind failing under load
#129 fixed a different flake in the same file (the udp port the OS hands out being taken on tcp), so this is not that one coming back.
History of this file, so the next person doesn't go round the same loop: #78 was the original report that the udp test assumed the tcp side of the same port is free, #129 fixed that by replacing the assumption with the retry loop this test now has, and PR #84 (still open, from before #129) proposed dropping the assertion instead.
The failure here is a different one: the loop would have to lose twenty times in a row to throw, and the run that failed took 14 ms, so the suspicion is an unhandled error event on one of the sockets the test itself binds rather than the assertion at the end.
Activity
A21-devs commentedon Dec 4, 2026
History of this file, so the next person doesn't go round the same loop: #78 was the original report that the udp test assumed the tcp side of the same port is free, #129 fixed that by replacing the assumption with the retry loop this test now has, and PR #84 (still open, from before #129) proposed dropping the assertion instead.
The failure here is a different one: the loop would have to lose twenty times in a row to throw, and the run that failed took 14 ms, so the suspicion is an unhandled
errorevent on one of the sockets the test itself binds rather than the assertion at the end.