Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the logic for detecting network availability issues #3945

Open
jamescrosswell opened this issue Feb 6, 2025 · 0 comments
Open

Improve the logic for detecting network availability issues #3945

jamescrosswell opened this issue Feb 6, 2025 · 0 comments

Comments

@jamescrosswell
Copy link
Collaborator

jamescrosswell commented Feb 6, 2025

See:

private static bool IsNetworkUnavailableError(Exception exception) =>
exception switch
{
// TODO: Could we make this more specific? Lots of these errors are unrelated to network availability.
HttpRequestException or WebException or IOException or SocketException => true,
_ => false
};

Some of the exception types we use to detect network availability issues are umbrella's for lots of potential root cause errors.

HttpRequestException, for example, has a StatusCode that could indicate any number of reasons why the request failed. Only a few of these would indicate network availability issues.

Similarly, the SocketError enum indicates all kinds of different root causes for a socket error.

This is complicated by the fact that these more specific codes appear to depend on the operating system where the HttpClient is running... so we'd need different code for different operating systems (at the very least, Windows + Others... hopefully Unix and macOS do more or less the same thing).

This is unrelated to this PR btw - I just noticed it when trying to identify, more specifically, a broken pipe exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant