This repository has been archived by the owner on Aug 23, 2019. It is now read-only.
fix: resolve transport sort order in browsers #333
Merged
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.
This fixes an issue with how browsers handle sorting. In Chrome, the existing code would always sort Circuit last. In Firefox, it does not. The existing logic doesn't take any consideration into the
b
argument of sort. The problem with this is you will get unreliable behavior because thea
andb
values are sorted as "equal" ifa
is not"Circuit"
.This PR changes the logic to always prioritize
a
if it is not"Circuit"
, and if it is, de-prioritize it.The caveat of this brief sort logic is that the other transports will have different orders in different browsers. This doesn't matter to Switch, it only cares that Circuit is last. This is why the test is set to only validate that part of the order.
required by ipfs/interop#63