Skip to content

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

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

Closed
DanTup opened this issue Jun 5, 2023 · 4 comments
Closed

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

DanTup opened this issue Jun 5, 2023 · 4 comments
Labels
area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …).

Comments

@DanTup
Copy link
Collaborator

DanTup commented Jun 5, 2023

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.

@milindgoel15
Copy link

#52487 (comment)

So what do you think about this?

@stevemessick stevemessick added the area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …). label Jun 5, 2023
@brianquinlan
Copy link
Contributor

This was caused by the fix for #50868

@brianquinlan
Copy link
Contributor

I think that the best approach is probably to change the way the debugger works. I have a proposal here: flutter/devtools#5883

@brianquinlan
Copy link
Contributor

I'm closing this in favor of the devtools issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …).
Projects
None yet
Development

No branches or pull requests

4 participants