Skip to content

Conversation

@plemarquand
Copy link
Contributor

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.

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.
@plemarquand plemarquand changed the title Improve Reliability of Reachability Detection when Fetching Dependencies Improve Reliability of Online/Offline Detection when Fetching Dependencies Nov 14, 2025
@plemarquand
Copy link
Contributor Author

@swift-ci test

@plemarquand plemarquand changed the title Improve Reliability of Online/Offline Detection when Fetching Dependencies Improve reliability of online/offline detection when fetching dependencies Nov 14, 2025
@plemarquand
Copy link
Contributor Author

@swift-ci test windows

2 similar comments
@plemarquand
Copy link
Contributor Author

@swift-ci test windows

@plemarquand
Copy link
Contributor Author

@swift-ci test windows

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.

1 participant