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

Nix hangs on network errors when downloading files #1183

Closed
wants to merge 2 commits into from

Conversation

ivan-tkatchev
Copy link

For some reason the default timeout when calling curl is 11.5 days, effectively infinite. This means that in case of network errors nix-shell or nix-build will hang forever trying to download files.

Changed the default timeout to 3 seconds.

@k0001
Copy link
Contributor

k0001 commented Jan 13, 2017

Maybe 3 seconds is too low? Can we make it 15 just in case?

@ivan-tkatchev
Copy link
Author

Ideally, I think, this should be configurable somewhere...

@aycanirican
Copy link
Member

+1
Reducing the timeout to 15 seconds solved my case too. Nix was unable to use binary cache via SSL on a centos machine.

[johndoe@localhost ~]$ nix copy -vvvvvv -r --store http://cache.nixos.org/ /nix/store/107m5z7x7p5aamzvy4j9xjan8li0jqpr-johndoe/bin/johndoe
starting download of http://cache.nixos.org/nix-cache-info
got header for ‘http://cache.nixos.org/nix-cache-info’: HTTP/1.1 200 OK
got header for ‘http://cache.nixos.org/nix-cache-info’: Content-Type: application/octet-stream
got header for ‘http://cache.nixos.org/nix-cache-info’: Content-Length: 51
got header for ‘http://cache.nixos.org/nix-cache-info’: Connection: keep-alive
got header for ‘http://cache.nixos.org/nix-cache-info’: Date: Tue, 17 Jan 2017 12:23:38 GMT
got header for ‘http://cache.nixos.org/nix-cache-info’: Last-Modified: Fri, 24 May 2013 20:33:25 GMT
got header for ‘http://cache.nixos.org/nix-cache-info’: ETag: "69d68de32bd6e6f0751e4cd5ae13e053"
got header for ‘http://cache.nixos.org/nix-cache-info’: Accept-Ranges: bytes
got header for ‘http://cache.nixos.org/nix-cache-info’: Server: AmazonS3
got header for ‘http://cache.nixos.org/nix-cache-info’: Age: 60143
got header for ‘http://cache.nixos.org/nix-cache-info’: X-Cache: Hit from cloudfront
got header for ‘http://cache.nixos.org/nix-cache-info’: Via: 1.1 e00584961bd0e81cd2b5bf84f9ffe964.cloudfront.net (CloudFront)
got header for ‘http://cache.nixos.org/nix-cache-info’: X-Amz-Cf-Id: -PpoRJtvKwEHA6MxVZsDbET-xVmp9I5nGSfLDuXMnGhplGassIjvaQ==
got header for ‘http://cache.nixos.org/nix-cache-info’:
finished download of ‘http://cache.nixos.org/nix-cache-info’; curl status = 0, HTTP status = 200, body = 51 bytes
starting download of http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: HTTP/1.1 404 Not Found
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Content-Type: binary/octet-stream
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Content-Length: 3
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Connection: keep-alive
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Date: Fri, 25 Nov 2016 19:10:09 GMT
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Last-Modified: Tue, 13 Sep 2016 10:54:19 GMT
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: ETag: "4f4adcbf8c6f66dcfc8a3282ac2bf10a"
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Accept-Ranges: bytes
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Server: AmazonS3
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Age: 43099
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: X-Cache: Error from cloudfront
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: Via: 1.1 e00584961bd0e81cd2b5bf84f9ffe964.cloudfront.net (CloudFront)
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’: X-Amz-Cf-Id: iWsMfSQ3N4kqZX5SUhTK1x4rZQ9jXPCUlUDZvxiqRtF2fk0AhvUKrg==
got header for ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’:
finished download of ‘http://cache.nixos.org/107m5z7x7p5aamzvy4j9xjan8li0jqpr.narinfo’; curl status = 0, HTTP status = 404, body = 3 bytes
error: path ‘/nix/store/107m5z7x7p5aamzvy4j9xjan8li0jqpr-johndoe’ is not valid
download thread shutting down
[johndoe@localhost ~]$ nix copy -vvvvvv -r --store https://cache.nixos.org/ /nix/store/107m5z7x7p5aamzvy4j9xjan8li0jqpr-johndoe/bin/johndoe.drv
starting download of https://cache.nixos.org/nix-cache-info
<--- thread 1 hangs here --->

@edolstra edolstra closed this in cc3b93c Jan 19, 2017
@edolstra
Copy link
Member

Curl does have a connect timeout, but it's pretty long:

$ time ./inst/bin/nix-prefetch-url https://invalid.org/foo
downloading ‘https://invalid.org/foo’... [0/0 KiB, 0.0 KiB/s]
error: unable to download ‘https://invalid.org/foo’: Couldn't connect to server (7)

real    2m9.875s
user    0m0.019s
sys     0m0.002s

However, there was an issue that Nix ignores Ctrl-C. That's fixed in cc3b93c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants