Skip to content

webrtc: Send RESET_STREAM on abrupt substream close#6

Open
timwu20 wants to merge 1 commit intotim/support-flagsfrom
tim/support-reset-stream
Open

webrtc: Send RESET_STREAM on abrupt substream close#6
timwu20 wants to merge 1 commit intotim/support-flagsfrom
tim/support-reset-stream

Conversation

@timwu20
Copy link
Copy Markdown
Collaborator

@timwu20 timwu20 commented Jan 15, 2026

Summary

When a Substream is dropped without calling shutdown() (graceful close), the SubstreamHandle now sends a RESET_STREAM flag to notify the remote peer of the abrupt termination. This follows the libp2p WebRTC specification for non-graceful stream termination.

Changes

  • Added reset_sent field to SubstreamHandle to track whether RESET_STREAM has been sent
  • Modified poll_next() to detect abrupt closes (when Substream is dropped without reaching FinAcked state) and send RESET_STREAM before signaling closure
  • Graceful closes (where shutdown() completes and state reaches FinAcked) do not send RESET_STREAM

Behavior

Closure Type What Happens
Graceful (shutdown() called, FIN_ACK received) SubstreamHandle returns None directly
Abrupt (Substream dropped without shutdown()) SubstreamHandle sends RESET_STREAM, then returns None

@timwu20 timwu20 marked this pull request as ready for review January 19, 2026 19:27
@timwu20 timwu20 requested a review from haikoschol January 19, 2026 19:27
@timwu20 timwu20 force-pushed the tim/support-reset-stream branch from 77b7678 to a517791 Compare January 26, 2026 21:58
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