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

Flutter test throws on Failed host lookup when debugging #137629

Closed
2 tasks done
thumbert opened this issue Oct 31, 2023 · 5 comments
Closed
2 tasks done

Flutter test throws on Failed host lookup when debugging #137629

thumbert opened this issue Oct 31, 2023 · 5 comments
Labels
r: solved Issue is closed as solved

Comments

@thumbert
Copy link

Is there an existing issue for this?

Steps to reproduce

Unfortunately I can only describe the problem verbally. It is very much similar to https://github.com/dart-lang/sdk/issues/53334

import 'package:http/http.dart' as http;
import 'package:flutter_test/flutter_test.dart';

Future<void> main() async {
   final uri = 'xxxx';  // internal server name
   var response = await http.get(Uri.parse(uri));
   print(response.statusCode);  // prints 200
 
  test('throws in debug mode!', () async {
    var response = await http.get(Uri.parse(uri));  // this line throws!
    expect(response.statusCode, 200);   // put a break point on this line and start debug
  });
}

If I run this file with flutter it runs OK. But if I start a debugging session, it throws inside the test.

If I run the same file with dart (using package test), it runs OK and it stops on the break point too (no issue!).

I don't understand what is flutter test doing that is different than a dart test in this regard.

The server name is a load balancer. If I run the flutter test with the underlying IP address of one of the servers behind the balancer, it does not throw. Because I can use the IP address directly, I have a workaround, but it would be nice if flutter test will do the same thing as dart test and not throw in debug mode.

Thanks,
T

Expected results

See above

Actual results

See above

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.13.9, on Microsoft Windows [Version 10.0.19044.3570], locale en-US)
    ! Warning: `dart` on your path resolves to C:\...\dart.exe, which is not inside your current Flutter SDK checkout at C:\...\flutter. Consider adding C:\...\flutter\bin to the front of your path.
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.6.4)
[!] Android Studio (not installed)
[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
[√] IntelliJ IDEA Community Edition (version 2023.2)
[√] VS Code (version 1.42.0)
[√] Connected device (3 available)
[√] Network resources

! Doctor found issues in 3 categories.
@darshankawar
Copy link
Member

Thanks for the report @thumbert
Can you provide the error log that shows while debugging the said test ?

I tried below code sample but with debug, I was able to get the test passed with 200 as status code.

200
00:04 +1: All tests passed!

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 1, 2023
@mraleph
Copy link
Member

mraleph commented Nov 1, 2023

@thumbert this should be fixed on beta (upcoming stable).

So either try switching to beta or as an alternative workaround you can try the following:

  1. In your Flutter SDK checkout in packages/flutter_tools/lib/src/test/runner.dart remove --chain-stack-traces line
  2. Remove flutter tool snapshots (rm $(dirname $(which flutter))/cache/*.snapshot)

Then debugger should no longer stop inside http/IO internals.

@cpuell
Copy link

cpuell commented Nov 3, 2023

Same on my side.. was working in previous version and i updated recently to 3.13.9 and it appeared, as far as i can remember it was fixed in previous version already..

@thumbert
Copy link
Author

@mraleph Confirming that your suggested "alternative workaround" fixes the issue. Thank you very much. Very useful.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 15, 2023
@dam-ease dam-ease added r: solved Issue is closed as solved and removed in triage Presently being triaged by the triage team labels Nov 16, 2023
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: solved Issue is closed as solved
Projects
None yet
Development

No branches or pull requests

5 participants