Skip to content

Conversation

@achingbrain
Copy link
Member

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.

Refs: libp2p/specs#575

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.
@achingbrain achingbrain requested a review from a team as a code owner September 13, 2023 14:21
Copy link
Member

@maschad maschad left a 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?

@achingbrain
Copy link
Member Author

I do wonder how frequently this is happening

Pretty frequently, it turns out. It's what causes this kind of CI failure.

@maschad
Copy link
Member

maschad commented Sep 13, 2023

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?

@maschad maschad marked this pull request as draft September 19, 2023 16:02
@maschad
Copy link
Member

maschad commented Sep 19, 2023

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

@maschad
Copy link
Member

maschad commented Sep 21, 2023

@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.

@maschad maschad marked this pull request as ready for review September 21, 2023 18:22
@maschad
Copy link
Member

maschad commented Oct 1, 2023

Closing in favour of #2073

@maschad maschad closed this Oct 1, 2023
achingbrain added a commit that referenced this pull request Oct 6, 2023
- 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 <[email protected]>
achingbrain added a commit that referenced this pull request Oct 6, 2023
- 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 <[email protected]>
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.

3 participants