Skip to content

feat: add configurable yamux close timeout for unread remote peers#219

Open
jxs wants to merge 2 commits into
libp2p:masterfrom
jxs:close-timeout
Open

feat: add configurable yamux close timeout for unread remote peers#219
jxs wants to merge 2 commits into
libp2p:masterfrom
jxs:close-timeout

Conversation

@jxs

@jxs jxs commented Feb 25, 2026

Copy link
Copy Markdown
Member

This introduces a configurable timeout for yamux connection shutdown, so poll_close can complete even when the remote peer stops reading from the underlying transport.
When the timeout elapses during yamux close, the implementation stops waiting on yamux-level frame draining and force-closes at the yamux state-machine level.

In backpressured scenarios (e.g. remote stops reading), graceful yamux shutdown may otherwise wait indefinitely while trying to flush pending frames. This change gives users a bounded close path for those situations.

Important: this timeout only affects yamux protocol-level shutdown behavior.
It does not replace transport/socket-level close semantics. For TCP-level behavior (e.g. FIN/RST/linger behavior), users should still configure socket options such as SO_LINGER as appropriate for their environment.

@jxs jxs requested a review from elenaf9 February 25, 2026 17:11

@ackintosh ackintosh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants