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

Failing dart pub get locks the terminal #4094

Closed
feinstein opened this issue Dec 22, 2023 · 4 comments
Closed

Failing dart pub get locks the terminal #4094

feinstein opened this issue Dec 22, 2023 · 4 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@feinstein
Copy link

feinstein commented Dec 22, 2023

Environment

  • Dart version (run dart --version): 3.1.5
  • OS kind and version (e.g. "Windows 10, version 1809" or "macOS 12.4"): MacOS Sonoma 14.2.1
  • Are you using the Chinese community mirror or a corporate firewall? No

Problem

I want to use dart pub get --enforce-lockfile in my CI to validate that the devs didn't forget to upload pubspec.lock after there was a change in pubspec.yaml (unfortunately I have seen this a lot), but in my tests dart pub get --enforce-lockfile locks the terminal and doesn't finish (you can see I had to hit ^C to stop it).

enforce lock file

So I can't use it and test if it returns an exit code different than 0 for the CI to validate.

EDIT: This is happening without the --enforce-lockfile flag as well.

@sigurdm
Copy link
Contributor

sigurdm commented Dec 22, 2023

Do you have a pubspec.yaml that reproduces this?

@sigurdm sigurdm added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Dec 22, 2023
@sigurdm sigurdm changed the title dart pub get --enforce-lockfile locks the terminal dart pub get locks the terminal Dec 22, 2023
@sigurdm
Copy link
Contributor

sigurdm commented Dec 22, 2023

Am I right in understanding that if you wait for some time (maybe 20 seconds) it will eventually exit?

In that case I can reproduce. I'm creating a fix.

@sigurdm
Copy link
Contributor

sigurdm commented Dec 22, 2023

When doing http requests with retries we retry on all http.ClientExceptions. Since #3317. This is necessary because a client can time out (eg after a long upload), resulting in a ClientException.

Problem is that we do speculative requesting of version-listings, but if the solver can detect a solve failure early, it will be reported, pub will close the shared http client.

Closing the client causes any ongoing speculative requests to fail immediately - with a ClientException - and thus retried 7 times, each time failing with another ClientException because the client is closed.

These retries prevent the dartdev process from exiting.

I have only been able to reproduce reliable on mac-os (tried also on linux). Using a pubspec with an unresolvable constraint. My guess is that on linux the ClientExceptions are thrown faster or something...

# pubspec.yaml
name: a
environment:
  sdk: ^3.0.0
  
homepage: 'http://abc.def'

dev_dependencies:
  test: ^0.2.0
> dart --version
Dart SDK version: 3.2.3 (stable) (Tue Dec 5 17:58:33 2023 +0000) on "macos_arm64"
> dart pub get 
Resolving dependencies... 
Because a depends on test ^0.2.0 which doesn't match any versions, version solving failed.


You can try the following suggestion to make the pubspec resolve:
* Try upgrading your constraint on test: dart pub add dev:test:^1.25.0
[....hanging for 10 seconds...]
>

@sigurdm sigurdm changed the title dart pub get locks the terminal Failing dart pub get locks the terminal Dec 22, 2023
@sigurdm
Copy link
Contributor

sigurdm commented Jan 22, 2024

Should be fixed now

@sigurdm sigurdm closed this as completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants