edolstra / nix-serve

A standalone Nix binary cache server
GNU Lesser General Public License v2.1
174 stars 37 forks source link

Getting NARs fails with "Transferred a partial file" #55

Closed the-sun-will-rise-tomorrow closed 7 months ago

the-sun-will-rise-tomorrow commented 7 months ago
$ nix --extra-experimental-features nix-command verify --store http://192.168.1.2:5000 /nix/store/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-bzip2-1.0.6.0.1

warning: 'verify' is a deprecated alias for 'store verify'
warning: error: unable to download 'http://192.168.1.2:5000/nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13y4x3gms97lxjyj0p8zjgpavzi6kihrablkb.nar': HTTP error 200 (curl error: Transferred a partial file); retrying in 278 ms
warning: error: unable to download 'http://192.168.1.2:5000/nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13y4x3gms97lxjyj0p8zjgpavzi6kihrablkb.nar': HTTP error 200 (curl error: Transferred a partial file); retrying in 621 ms
warning: error: unable to download 'http://192.168.1.2:5000/nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13y4x3gms97lxjyj0p8zjgpavzi6kihrablkb.nar': HTTP error 200 (curl error: Transferred a partial file); retrying in 1223 ms
warning: error: unable to download 'http://192.168.1.2:5000/nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13y4x3gms97lxjyj0p8zjgpavzi6kihrablkb.nar': HTTP error 200 (curl error: Transferred a partial file); retrying in 2694 ms
[0.0/0.1 MiB DL, 1/0/1 paths verified] downloading 'http://192.168.1.2:5000/nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13 error: interrupted by the user

On the server (with STARMAN_DEBUG=1):

Apr 04 22:05:59 nix nix-serve[996013]: 2024/04/04-22:05:59 CONNECT TCP Peer: "[192.168.1.1]:46412" Local: "[192.168.1.2]:5000"
Apr 04 22:05:59 nix nix-serve[996013]: [996013] Read 238 bytes: "GET /nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13y4x3gms97lxjyj0p8zjgpavzi6kihrablkb.nar HTTP/1.1\r\nHost: 192.168.1.2:5000\r\nUser-Agent: curl/8.4.0 Nix/2.19.1\r\nAccept: */*\r\nAccept-Encoding: zstd, br, gzip, deflate, bzip2, xz\r\n\r\n"
Apr 04 22:05:59 nix nix-serve[996013]: warning: the group 'nixbld' specified in 'build-users-group' does not exist
Apr 04 22:05:59 nix nix-serve[996013]: [996013] Wrote 129 bytes
Apr 04 22:05:59 nix nix-serve[996013]: [996013] Request done
Apr 04 22:05:59 nix nix-serve[996013]: [996013] Waiting on previous connection for keep-alive request...
Apr 04 22:06:00 nix nix-serve[996013]: [996013] Closing connection

Checking with cURL, it looks like the server is closing the connection just as it would start sending the response body:

$ curl -v http://192.168.1.2:5000/nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13y4x3gms97lxjyj0p8zjgpavzi6kihrablkb.nar
*   Trying 192.168.1.2:5000...
* Connected to 192.168.1.2 (192.168.1.2) port 5000
> GET /nar/z0sf96nxxw6qdl5yf1vl0sn07cnh1fqd-1yj7zp35yz8y1hd13y4x3gms97lxjyj0p8zjgpavzi6kihrablkb.nar HTTP/1.1
> Host: 192.168.1.2:5000
> User-Agent: curl/8.5.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/plain
< Content-Length: 80904
< Date: Thu, 04 Apr 2024 22:05:32 GMT
< Connection: keep-alive
< 
* transfer closed with 80904 bytes remaining to read
* Closing connection
curl: (18) transfer closed with 80904 bytes remaining to read
the-sun-will-rise-tomorrow commented 7 months ago

Looks like this can happen if the Nix bin directory is not in PATH.

Maybe a better error message somewhere would be nice, but as this is not nix-serve's fault, closing.