Random Walk Peer discovery adds connections to same peer

I’m not sure if this is intended behaviour or not:
I just activated peer discovery via DHT random walk. My nodes find each other as wanted. I log every new connection and the number of connections in the connectionManager.
The nodes repeatedly create connections to each other. I have 4 nodes in total and expect each to have 3 connections but after some minutes I already have 30 connections per node.
Is this intended? If so: Can I prevent multiple connections to each node?

Edit: I added the code, so that you can try it yourself: https://github.com/Strernd/libp2p-example

Thanks for sharing the example, I will take a look, it should not be doing that. At most you should have 2 connections to a peer (1 inbound and 1 outbound), this occurs when nodes dial one another at the same time.

Let me know if I can support you.

We just released a patch for the dht, can you verify yarn add libp2p-kad-dht@latest fixes the problem? I ran that locally and things look good.

It works. Thanks for the quick fix.