-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(@libp2p/webrtc): delay closing datachannels #2048
Conversation
Tactical fix until we can update the spec to coordinate closing datachannels. Calling `.close` on a datachannel causes a stream reset - depending on the implementation there's a good chance any data waiting to be transmitted will be lost. As a workaround when closing a datachannel wait until it's `.bufferedAmount` property is `0`, then wait a bit longer before closing the channel. This is because although Firefox will have sent all the data by this point, Chrome may have not. This should be removed when the spec is updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I have two questions. Also I do wonder how frequently this is happening, do you think it would make sense to instrument this to measure that?
Pretty frequently, it turns out. It's what causes this kind of CI failure. |
Have you ran that test a few times on CI to ensure that this fix solves it? |
As discussed in triage, this may actually be an issue with Chrome, @achingbrain will file a report. Update: Report filed https://bugs.chromium.org/p/chromium/issues/detail?id=1484907 |
@achingbrainI I am re-opening this as it will unblock CI without us having to skip the test entirely, until https://bugs.chromium.org/p/chromium/issues/detail?id=1484907 is resolved. |
Closing in favour of #2073 |
- Gracefully close streams on muxer shutdown - Refactor initiator/recipient flows for clarity - Wait for `bufferedAmount` to be `0` before closing a datachannel - Close datachannels on both initiator and recipient - Implements FIN_ACK for closing datachannels without data loss Supersedes #2048 --------- Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
- Gracefully close streams on muxer shutdown - Refactor initiator/recipient flows for clarity - Wait for `bufferedAmount` to be `0` before closing a datachannel - Close datachannels on both initiator and recipient - Implements FIN_ACK for closing datachannels without data loss Supersedes #2048 --------- Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
Tactical fix until we can update the spec to coordinate closing datachannels.
Calling
.close
on a datachannel causes a stream reset - depending on the implementation there's a good chance any data waiting to be transmitted will be lost.As a workaround when closing a datachannel wait until it's
.bufferedAmount
property is0
, then wait a bit longer before closing the channel.This is because although Firefox will have sent all the data by this point, Chrome may have not.
This should be removed when the spec is updated.
Refs: libp2p/specs#575