Clear dial timeout to terminate signal exchange on error/success #661
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.
The dial timeout is not stored or cleared. We also set the
successfulflag, which is used asynchronously. This creates a potential race condition where the timeout could be evoked beforesuccessfulis updated. This change stores the dial timeout and ensures it is cleared after a connection attempt is made. This should avoid the potential termination of already successful connections.This PR also introduces some unit tests around
dialWebRTC. The tests rely heavily on mocks, but they at least add some layer of assertion that the code behaves as expected. Ideally, as more tests are added, additional fixtures can be added to harden our tests.Finally, just a little cleanup to avoid ignoring eslint rules.
Note: This is not a permanent fix, but more of a band-aid. Ultimately, this logic is frail. Mixing timeouts with the results of promises can lead to unexpected behavior. We should consider refactoring this code path to avoid that.