Skip to content

implement a flush capability for data channels#63

Open
cuchaz wants to merge 2 commits intowebrtc-rs:masterfrom
cuchaz:flush
Open

implement a flush capability for data channels#63
cuchaz wants to merge 2 commits intowebrtc-rs:masterfrom
cuchaz:flush

Conversation

@cuchaz
Copy link
Copy Markdown

@cuchaz cuchaz commented Mar 19, 2026

Hello again,

In my application, it is useful to know when a data channel message has "finished" sending (but not necessarily received by the remote peer), so I've implemented a flush-like capability. It works by inserting a special flush meta-message into the processing pipeline (including the SCTP stream) which can be polled later using a specialized function. If I've implemented this correctly, the flush message should not be pollable until all the socket datagrams corresponding to all previous data channel message are also pollable.

This may not be the simplest way to implement a feature like this, but it's the first way I've found so far that works. It modifies a lot of different layers of the processing pipeline, so I realize it may not be such a welcome change.

Would you be interested in adding a flush feature to data channels? The attached PR is a draft implementation to illustrate the idea, but I don't know if it's really the best way to do this. Maybe you know of a better way? Or maybe this is a good enough starting point and we work on it from here.

Thanks,
Jeff

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 42.85714% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.11%. Comparing base (9feb4a3) to head (1541c17).

Files with missing lines Patch % Lines
rtc/src/peer_connection/handler/sctp.rs 40.62% 38 Missing ⚠️
rtc/src/peer_connection/handler/mod.rs 5.26% 18 Missing ⚠️
rtc/src/peer_connection/handler/datachannel.rs 7.14% 13 Missing ⚠️
rtc-sctp/src/association/stream.rs 0.00% 9 Missing ⚠️
rtc/src/peer_connection/message/internal.rs 0.00% 9 Missing ⚠️
rtc/src/data_channel/mod.rs 0.00% 8 Missing ⚠️
rtc/src/peer_connection/handler/demuxer.rs 0.00% 8 Missing ⚠️
rtc-sctp/src/queue/pending_queue.rs 88.37% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #63      +/-   ##
==========================================
- Coverage   71.17%   71.11%   -0.07%     
==========================================
  Files         442      442              
  Lines       67330    67452     +122     
==========================================
+ Hits        47922    47966      +44     
- Misses      19408    19486      +78     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant