dart-lang / tools

This repository is home to tooling related Dart packages.
BSD 3-Clause "New" or "Revised" License
29 stars 20 forks source link

Don't let analytics block `dart` commands #216

Open Levi-Lesches opened 9 months ago

Levi-Lesches commented 9 months ago

When on an unreliable internet connection, or a W/LAN network without actual Internet access (such that internet access hangs but doesn't outright fail), Dart's analytics can block any command, like dart run, dart compile, or dart analyze from running. Running dart --disable-analytics fixes the problem, but without knowing the cause ahead of time, it's difficult to know what the issue is or how to fix it.

eliasyishak commented 9 months ago

@Levi-Lesches does the process hang indefinitely or does it eventually finish?

@parlough was this fixed with your recent change in Gerrit or is this unrelated?

https://dart-review.googlesource.com/c/sdk/+/339500

Levi-Lesches commented 7 months ago

Sorry, I read this notification and then forgot to respond... but I did have to set up another device without internet the other day, and this still happens on Dart stable 3.2.6.

The process hangs indefinitely, and disabling analytics does stop it from happening again.

eliasyishak commented 7 months ago

What command are you running that is causing it to hang when you aren't connected to the internet? I am try to setup a repro on my end.

Can you also provide the output from flutter doctor -v? I am currently on the stable release on my mac and I am running into this error

eliasyishak-macbookpro:~ eliasyishak$ flutter doctor -v
[✓] Flutter (Channel stable, 3.16.9, on macOS 14.3 23D56 darwin-arm64, locale en)
    • Flutter version 3.16.9 on channel stable at /Users/eliasyishak/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41456452f2 (3 weeks ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/eliasyishak/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)
    • IntelliJ at /Users/eliasyishak/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9161.38/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.86.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.82.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.3 23D56 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 121.0.6167.160

[✓] Network resources
    • All expected network resources are available.

• No issues found!
eliasyishak commented 7 months ago

The process hangs indefinitely, and disabling analytics does stop it from happening again.

@bkonyi, did you ever see the process hang indefinitely or just for a few seconds when you made your fix in https://dart-review.googlesource.com/c/sdk/+/339500

bkonyi commented 7 months ago

The process hangs indefinitely, and disabling analytics does stop it from happening again.

@bkonyi, did you ever see the process hang indefinitely or just for a few seconds when you made your fix in https://dart-review.googlesource.com/c/sdk/+/339500

It wasn't my fix :-) However, we did have similar issues with the legacy analytics that was resolved by https://dart-review.googlesource.com/c/sdk/+/294940. Maybe we need to do something similar?

eliasyishak commented 7 months ago

whoops my mistake @bkonyi, @parlough does this look familiar to you?

legacy analytics that was resolved by https://dart-review.googlesource.com/c/sdk/+/294940. Maybe we need to do something similar?

And we did implement something similar to this, except we hard coded the default timeout to be 250ms when we invoke the Analytics.close() method in this PR https://github.com/dart-lang/tools/pull/184

parlough commented 7 months ago

That change did fix a few of the (non-indefinite hanging) issues I was seeing, but I'm not sure about the situation where the connection itself is unstable or hanging.

Neither that change nor the one from https://github.com/dart-lang/tools/pull/184 are in the 3.2 stable branch though, so I think it'd be worth seeing if this reproduces on 3.3? @Levi-Lesches would you be able to try with a 3.3 beta build or revisit this once a stable release is made?

Levi-Lesches commented 7 months ago

When I set up my next Raspberry Pi I will give 3.3 a quick shot to check 👍