Commit 2096cff
authored
Improve reliability of online/offline detection when fetching dependencies (swiftlang#9378)
When fetching dependencies on Darwin we relied on SCNetworkReachability
to determine if the user is offline when a dependency fetch fails. This
check considered `SCNetworkReachabilityFlags.transientConnection` to be
considered "offline", however this state still has connectivity.
If the user had the dependency cached, this would result in the cached
local dependency being used instead of a fetch of the latest dependency.
Ultimately this meant very occasionally the user may end up with a stale
dependency when they had all the requirements met to ge the latest one.
Move off of the SCNetworkReachability APIs as they're not really
recommended for determining online status, and simply check if the fetch
failed with a "Could not resolve host" error. This is what we actually
want to check for anyway. Even if the host is down but the connection is
fine the host being down is what is relevant to whether or not we should
try and use the cached dependency.1 parent 84b3e6e commit 2096cff
1 file changed
+12
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
347 | | - | |
348 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
349 | 351 | | |
350 | 352 | | |
351 | 353 | | |
| |||
645 | 647 | | |
646 | 648 | | |
647 | 649 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
684 | 656 | | |
685 | | - | |
686 | 657 | | |
687 | 658 | | |
688 | | - | |
689 | 659 | | |
0 commit comments