Fix data channel close race condition#1978
Open
1egoman wants to merge 5 commits into
Open
Conversation
…ving handlers So now the order is: 1. Detach handlers 2. Run dc.close() 3. After 1+2 have run for all data channels, THEN call pcManager.close()
…s actually what should be checked
🦋 Changeset detectedLatest commit: 8db768c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1953 (I think, still needs confirmation from the reporter - I was unable to reproduce locally).
In
main, there is a possible race condition that could happen when disconnecting a room. The below three tasks run in this order:What could happen is that when 1 would run, it would close the data channels pre-emptively and lead to some of the handlers (3) firing before they were cleaned up, leading to a
Unknown DataChannel error on ...error being logged.So to fix this, reorder the above to now run in 3 -> 2 -> 1 order. This means that by the time any data channel errors that occur during disconnect are fired (at 1), the handlers are already detached (3).
As an unrelated fix, also,
Unknown DataChannel error on ...shouldn't have been logged in this case. It looks like this was because of theevent instanceof ErrorEventcheck - actually,eventwould be aRTCErrorEventand confusingly given their names,RTCErrorEventdoes not extendErrorEvent. So, alter this code to check the right error which should make these error paths show more detail.