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

dart run test w/o internet resulted in "Got socket error trying to find package analyzer ..." #3880

Open
srawlins opened this issue Apr 17, 2023 · 5 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@srawlins
Copy link
Member

srawlins commented Apr 17, 2023

I was on a plane, w/o internet, and tried to run dart run test test/version_test.dart in the linter repo. My pubspec.yaml was out of date compared with .dart_tool/package_config.yaml (unbeknownst to me). I think it had some dependency_overrides for analyzer and _fe_analyzer_shared:

$ ~/code/dart-sdk/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart run test test/version_test.dart
Resolving dependencies in /Users/srawlins/code/dart-linter... (27.7s)
Got socket error trying to find package analyzer at https://pub.dev.
$ ~/code/dart-sdk/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart --version
Dart SDK version: 3.0.0-edge.64ca878d191444046943ec81c34f6dc781a384e2 (be) (Tue Apr 4 14:34:32 2023 -0700) on "macos_x64"

More interesting info:

  1. When I landed, and tried to reproduce by turning off my Mac's WiFi, I instead got a much better failure mode, where the process would try to resolve dependencies for about 75 seconds, then give up, and run the test successfully. I was unable to reproduce the socket error.
  2. It seemed silly, but on my return flight, I tried to reproduce, as I had not captured the error to report it, and sure enough, it reproduced. I don't know what is different between plane-w/o-internet and wifi-turned-off.
  3. I found out, between flights, about dart run --no-pub, but it was not in the help text (e.g. dart run --help).

Some possible resolutions:

  • Have a timeout failure mode (like the 75 second failure mode when my WiFi was turned off), or anything other than "Got socket error; exit".
  • Add --no-pub to the help text.

If the socket thing is an issue to be resolved in dart-lang/pub, I'm happy to track this issue over there.

@mit-mit
Copy link
Member

mit-mit commented Apr 17, 2023

cc @sigurdm any idea why pub has different behavoir here?

@sigurdm
Copy link
Contributor

sigurdm commented Apr 18, 2023

any idea why pub has different behavior here?

My guess is that this is down differences in OS behavior when trying to open a socket with wifi on, but not connected and off. Why it would work like that I don't know.

Not sure if we have a reliable way to detect network availability on desktop. If WIFI is off we should ideally not wait at all, but just give up.

To me the "socket error" seems easier to understand than the long wait - but maybe I'm misunderstanding something.

Also I don't understand why it runs the tests after giving up in the WIFI-off case. I would have expected it to halt.

@sigurdm
Copy link
Contributor

sigurdm commented Apr 18, 2023

When I turn off WIFI on my mac I get a 26 second wait, and then a socket error:

> dart run test
Resolving dependencies in /Users/sigurdm/projects/blah... (26.9s)
Got socket error trying to find package test at https://pub.dev.

@sigurdm sigurdm transferred this issue from dart-lang/sdk Apr 18, 2023
@srawlins
Copy link
Member Author

Also I don't understand why it runs the tests after giving up in the WIFI-off case. I would have expected it to halt.

Mmm you may be correct. I may be misremembering that.

@sigurdm
Copy link
Contributor

sigurdm commented Sep 14, 2023

We should probably implement platform-specific internet-availability checks, and if we detect that no internet is available, don't wait for a time-out, but instead attempt to resolve with --offline.

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants