Repository navigation
Closed
Labels
Description
I'm seeing this in my build logs:
┃ error: unable to download 'https://nix-cache.cluster.ifcsn0.nasreddine.com/nar/02va3djp92prpvzxq1j1s76if8rqwdy0pj14vr8bg7rw8q6q5dip.nar.xz': HTTP error 200 (curl error: Timeout was reach…
┃ error: unable to download 'https://nix-cache.cluster.ifcsn0.nasreddine.com/nar/18jipp01ps94mh4spxyb9hzdl2via30l7wq7s9m53rbx3zm9c17l.nar.xz': HTTP error 200 (curl error: Timeout was reach…
┃ error: unable to download 'https://nix-cache.cluster.ifcsn0.nasreddine.com/nar/0q3q5pzrzk102f5n6jsg5mzxbq7s3j85hzsg2gkznqaqmp581f9g.nar.xz': HTTP error 200 (curl error: Timeout was reach…
┃ error: unable to download 'https://nix-cache.cluster.ifcsn0.nasreddine.com/nar/1d1qisvbvqargbxcszbalnghjp3gvmbqcprv732rmq9qxljwv9gj.nar.xz': HTTP error 200 (curl error: Timeout was reach…
┃ error: unable to download 'https://nix-cache.cluster.ifcsn0.nasreddine.com/nar/1db6xn18w1j2ixwds0cv2p3zf306aka87cap1kvybxzj66cdn19m.nar.xz': HTTP error 200 (curl error: Timeout was reach…
┃ error: unable to download 'https://nix-cache.cluster.ifcsn0.nasreddine.com/nar/0nl1nwwkm6kx8pab4w07dcsihjbi8npmwjfzx2mpljiap9i2ijc1.nar.xz': HTTP error 200 (curl error: Timeout was reach…
This is because ncps first pulls the file locally, and then streams it down. Explore a way to stream it as it's being pulled down, but without first storing it in memory!
Reacted by Jeremiah, InternetUnexplorer, Peter Majchrak and Jonas Sander
Reacted by sokai
Activity
sss123next commentedon Jun 25, 2025
you probably can stream bytes on the fly, if resigning with local key is not used
Jonas-Sander commentedon Jul 15, 2025
I tried with AI for a few hours (I'm not a Go developer) but I give up now xD
For reference, maybe something can be taken from it https://github.com/kalbasit/ncps/compare/45aa06ffcbcdcd10b93e033ea94594082d7b9e44...Jonas-Sander:ncps:stream-nar-downloads?expand=1
kalbasit commentedon Aug 23, 2025
@sss123next yes that's the idea but there's a bit of complexity to that with how it currently works:
In order for ncps to "stream" the response to the client as it's being pulled, it needs to be able to do so for as many clients requesting the same nar ; But the nar is being streamed to a file so the bytes are not accessible yet as the file is open for write and the kernel will need to sync it to make it readable by other processes.
I'm not sure what's the best approach for this yet, hence why I left it open. The only way I can possibly see this working is to store nar in memory first before writing it to disk but that can quickly get out of hand as ncps pulling many nars and risking memory starvation. I'd appreciate someone 2-cents on this.
kalbasit commentedon Aug 23, 2025
Gemini seems to have a good idea making this work using
sync.Condand writing to the final file partially allowing clients to read in chunks. Is anyone interested in giving this a shot? Implementation must keep in mind that the store is currently only local file but I do plan to add S3 support among others.https://g.co/gemini/share/115906653191
feat: Stream NAR downloads to clients while still downloading (#272)
kalbasit commentedon Aug 25, 2025
@sss123next @Jonas-Sander please try v0.3.0-rc1 as it does fix this issue. I just tested it pulling ~300M from two curl sessions and both got to first byte pretty quickly.
Jonas-Sander commentedon Aug 26, 2025
Awesome that you got it working! ^^
I'm really short on time at the moment, maybe next weekend I can try it out.
sss123next commentedon Sep 7, 2025
thx, i have installed update, a bit busy right now to do deep testing, but i will watch for errors on large files downloading.
sss123next commentedon Sep 8, 2025
have a lot of errors like this on very weak (overloaded) connection.
probably some tuning for timeouts can be implemented
kalbasit commentedon Sep 8, 2025
@sss123next can you open a new issue as this is unrelated. The timeout currently is 3s:
ncps/pkg/cache/upstream/cache.go
Line 31 in 7598ec6