Skip to content

Avoid thrown/caught exceptions when using HttpClient.openUrl (and related methods) with hostnames #52423

Closed
@DanTup

Description

@DanTup

In a recent change (d884d1a) to fix #50868, there are calls to _InternetAddress.fromString() that will throw (and then catch) ArgumentError whenever the URI contains a hostname and not an IP address.

This is not itself a bug/problem and everything works as expected. However, a lot of users are running with "break on all exceptions" ticked in VS Code and breaking here is causing some confusion. I've explained the issue here although that's not very visible unless you read the entire thread.

I think that issue should probably be closed (because as far as I can tell everything is working as expected), but since fetching URLs using hostnames is very common I thought it was worth seeing if that code could be altered to not rely on throwing/catching for this flow. While I think users shouldn't generally run with "Break on all exceptions" enabled (the default is "Break on uncaught exceptions"), the less "noise" there is when running in that mode, the easier it'll be to track down actual issues caused by unexpected exceptions being thrown and caught.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onarea-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.cherry-pick-candidateCandidates to be cherry-pickedlibrary-io

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions