Skip to content

Request flood in web browser #12

Closed
@lidel

Description

@lidel

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 🎠 💦

pending-swarm-connect-2019-07-12--22-35-50

swarm-connect-content-routing-2019-07-12--22-38-42

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:

net-insufficient-resources-2019-07-12--21-37-15

Fix

My initial idea would be to limit the number of concurrent requests using something like p-queue around these lines:

const results = await Promise.all(
addrs.map((addr) => {
return this.swarm.connect(addr.toString()).catch(() => {})

I'll prepare PR with this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions