Description
Problem
I've been testing delegated routing in browser context, namely with js-ipfs embedded in Brave (ipfs/ipfs-companion#716).
It produces pretty intense list of pending requests when browsing /ipns/tr.wikipedia-on-ipfs.org 🎠 💦
Modern browsers limit the number of concurrent requests to ~6 per hostname.
Everything over the limit lands in "pending" state.
On some pages it takes a dozen of seconds for the browser to finish a pending list like the one above (it was multiple screens), and while it happens nothing else works.
When run in regular page, this flood of swarm connect
results in slow browsing experience (nothing loads, "waiting for available socket" displayed in bottom left).
In my case (Brave + chrome.sockets), coupled with regular preload requests it produced more severe net::ERR_INSUFFICIENT_RESOURCES
:
Fix
My initial idea would be to limit the number of concurrent requests using something like p-queue around these lines:
js-libp2p-delegated-content-routing/src/index.js
Lines 90 to 92 in 69f1f94
I'll prepare PR with this.