Wrap GetHostAddresses/Async calls to catch SocketException#5664
Merged
NinoFloris merged 3 commits intonpgsql:mainfrom Oct 29, 2025
Merged
Wrap GetHostAddresses/Async calls to catch SocketException#5664NinoFloris merged 3 commits intonpgsql:mainfrom
NinoFloris merged 3 commits intonpgsql:mainfrom
Conversation
NinoFloris
approved these changes
Oct 29, 2025
Member
NinoFloris
left a comment
There was a problem hiding this comment.
Thanks for doing this, I've made some tweaks to your PR but otherwise LGTM!
ref: removed redundant catch/throw
d0ab5e0 to
ffd29b0
Compare
vonzshik
reviewed
Nov 5, 2025
Comment on lines
+1332
to
+1333
| ipAddresses = await Dns.GetHostAddressesAsync(Host, cancellationToken) | ||
| .WaitAsync(timeout.CheckAndGetTimeLeft(), cancellationToken).ConfigureAwait(false); |
Contributor
There was a problem hiding this comment.
@NinoFloris I'm pretty sure before it was calling TaskTimeoutAndCancellation.ExecuteAsync instead of Dns.GetHostAddressesAsync directly
Member
There was a problem hiding this comment.
IMO this became obsolete after we removed the ifdefs for <= 6.0
Member
There was a problem hiding this comment.
Let me put up a PR to pull it out entirely and fix the timeout flowing into the token.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #5606.
The GetHostAddresses method also throws:
ArgumentOutOfRangeException, if the host name exceeds 255 chars;ArgumentNullException, if the host name is null;ArgumentException, if the host address is an invalid IP address.Should these other exceptions be wrapped into a NpgsqlException as well?