Skip to content

Large files cause timeout issues downstream #20

Closed

Description

@kalbasit

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!

Activity

  1. added
    enhancement
    bug
    on Dec 6, 2024
  2. sss123next commented on Jun 25, 2025

    @sss123next

    you probably can stream bytes on the fly, if resigning with local key is not used

  3. Jonas-Sander commented on Jul 15, 2025

    @Jonas-Sander
  4. kalbasit commented on Aug 23, 2025

    @kalbasit
    OwnerAuthor

    @sss123next yes that's the idea but there's a bit of complexity to that with how it currently works:

    • Nix does a ncps/xyz.narinfo
    • ncps pulls the narinfo and immediately starts pulling the nar from upstream and streams it directly to the store (i.e local file)
    • Nix requests ncps/nar
    • ncps notices there's a goroutine pulling it already so it just sits and waits for that to finish before it can start streaming the nar back from the local store.

    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.

  5. kalbasit commented on Aug 23, 2025

    @kalbasit
    OwnerAuthor

    Gemini seems to have a good idea making this work using sync.Cond and 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

  6. added a commit that references this issue on Aug 24, 2025
    65733dc
  7. kalbasit commented on Aug 25, 2025

    @kalbasit
    OwnerAuthor

    @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.

  8. Jonas-Sander commented on Aug 26, 2025

    @Jonas-Sander

    @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.

    Awesome that you got it working! ^^

    I'm really short on time at the moment, maybe next weekend I can try it out.

  9. sss123next commented on Sep 7, 2025

    @sss123next

    thx, i have installed update, a bit busy right now to do deep testing, but i will watch for errors on large files downloading.

  10. sss123next commented on Sep 8, 2025

    @sss123next
    warning: error: unable to download 'http://nixos-cache-proxy.dark-alexandr.net/nar/0fnxj89hxrzfpg0a7zwgj5lxyw9zvirz8s5byiybzbsh56kr5h6l.nar.xz': HTTP error 500
    
           response body:
    
           error performing the request: Get "https://cache.nixos.org/nar/0fnxj89hxrzfpg0a7zwgj5lxyw9zvirz8s5byiybzbsh56kr5h6l.nar.xz": http2: timeout awaiting response headers; retrying in 350 ms
    warning: error: unable to download 'http://nixos-cache-proxy.dark-alexandr.net/nar/0fnxj89hxrzfpg0a7zwgj5lxyw9zvirz8s5byiybzbsh56kr5h6l.nar.xz': HTTP error 500
    
           response body:
    
           error performing the request: Get "https://cache.nixos.org/nar/0fnxj89hxrzfpg0a7zwgj5lxyw9zvirz8s5byiybzbsh56kr5h6l.nar.xz": http2: timeout awaiting response headers; retrying in 550 ms
    

    have a lot of errors like this on very weak (overloaded) connection.

    probably some tuning for timeouts can be implemented

  11. kalbasit commented on Sep 8, 2025

    @kalbasit
    OwnerAuthor

    @sss123next can you open a new issue as this is unrelated. The timeout currently is 3s:

    defaultHTTPTimeout = 3 * time.Second

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions