Skip to content

"Failed host lookup" caught exception when using http.openUrl() #52615

Closed
@DanTup

Description

@DanTup

This is related to flutter/flutter#126650 / #52423. Dart 3 changed some code that resulted in a caught exception when doing HTTP requests. Many users are currently running with "break on all exceptions" (something I recommend against, but still seems very common).

That issue was fixed and subsequently cherry-picked in #52487. However, running the same code has the same behaviour with the fix, because there is another caught exception.

Example code:

import 'dart:io';

import 'package:flutter/material.dart';

main() async {
  var client = HttpClient();
  var req = await client.openUrl("get", Uri.parse("https://www.bbc.co.uk"));
  var resp = await req.close();
  print(resp.statusCode);

  return runApp(const MaterialApp(
      home: Scaffold(
    body: Center(child: Text("Hello")),
  )));
}

image

The error suggests it failed to resolve www.bbc.co.uk, although that's definitely a valid host that resolves. Not pausing on caught exceptions works fine and the request completes (I see a 200 status code printed).

This isn't the same problem as the original (it's a different exception), but the cherry-pick here unfortunately hasn't changed anything as far users see - there is still a caught exception here, it just happens to be a slightly different one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-sdkUse area-sdk for general purpose SDK issues (packaging, distribution, …).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions