holepunchto / hyperswarm

A distributed networking stack for connecting peers.
https://docs.holepunch.to
MIT License
1.04k stars 84 forks source link

reduce test flakiness #54

Closed davidmarkclements closed 2 years ago

davidmarkclements commented 4 years ago

when tests are run multiple times eventually they stall, usually because of a listen callback or listener event is missed. There appears to be a complex relationship causing a race condition between the microtask queue (as we're using promises/await in test) and the retry logic (in @hyperswarm/network and it's underlying stack). We still need to get to the bottom of that, however we can mitigate the chances of that occurring by ensuring that every test closes out any socket connections before ending, which is mostly what this PR does. There are also a few cases where using timeouts in tests proved brittle (e.g. the deup test) so I've found a different approach in these cases