rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

fix(stream): propagate backpressure instead of silently dropping dial requests

Open sneaxhuh opened this issue 4 weeks ago • 0 comments

Fixes #6157

When opening hundreds of streams per second, dial requests were being silently dropped because try_send() would fail when the channel was full, causing Control::open_stream() to hang indefinitely.

This commit implements backpressure propagation as suggested by maintainers:

  1. Increased dial_sender channel buffer from 0 (rendezvous) to 32 to handle burst traffic without blocking on every request.

  2. Replaced try_send() with send().await in the dial path to propagate backpressure when >32 dial requests are pending, instead of silently dropping them.

  3. Refactored Shared::sender() to return a cloned dial_sender, allowing the async send operation to happen outside the mutex lock to prevent deadlocks.

With these changes:

  • Up to 32 concurrent dial requests queue immediately
  • Additional requests block until space is available (backpressure)
  • Errors are properly propagated instead of silent failures
  • No more indefinite hangs on dropped dial requests

sneaxhuh avatar Nov 30 '25 14:11 sneaxhuh