Repository navigation
Description
Zig Version
0.12.0-dev.790+ad6f8e3a5
Steps to Reproduce and Observed Behavior
My project (Ghostty) has ~20 dependencies it has to fetch from the internet given an uncached build. These are fetched from multiple sources (github, gitlab, self-hosted, etc.). Each push results in ~7 separate CI runs which run uncached. As a result, each Git push results in ~140 new HTTP fetches for these large files.
Even with this relatively small number, its big enough that I'm regularly seeing temporary errors fail CI. These are the sorts of errors that an immediate retry fixes the issue 90% of the time, and a very short backoff fixes the issue the remaining 10% of the time. So far, none of the failures have been real persisted outages.
Expected Behavior
Zig should retry on fetch errors.
The ones I've seen but this likely isn't exhaustive:
error.TemporaryNameServerFailuretemporary is even in the name!- HTTP 500 errors, namely 502 which is usually a single backend down while others are still up
- HTTP 400 errors even, I've received a 404 before when the package existed, likely a CDN issue where some edges have it and others don't
My recommendation would be to do a short series of backoffs. Even backing off a few times with a maximum total wait time of 10 seconds would probably fix 90% of my issues, but perhaps this can be configurable because for CI I'd happily configure this to upwards of a few minutes.
The backoff should probably increase, whether it be exponential, fibbonacci, whatever.
As a workaround, I can make my whole CI job retry, but the CI job does a lot of other setup and no other steps in the job are flaky so this would probably result in retrying genuine failures and cost me more money. It'd be much more convenient and faster if Zig retried.
Activity
Package.Fetch: retry fetch on error
Package.Fetch: retry fetch on error
Package.Fetch: retry fetch on error
andrewrk commentedon Oct 1, 2024
Still interested in solving this issue, but wanted to suggest an alternative workaround for the time being. Could you try persisting your
pdirectory in the global zig cache across CI invocations? Or maybe even your entire global zig cache directory since you're using the same zig version.I think it's a nice workaround because it's something valuable to do regardless - will make your CI run faster and use less network resources. For example, mlugg's Setup Zig Action does this by default.
mitchellh commentedon Oct 1, 2024
We are doing this now! This plus I've mirrored all my dependency in a single web host I use has made this a non-issue for me. I think generally its still useful to solve but I have successfully worked around it.
mitchellh commentedon Oct 26, 2025
As an update here, note that the "mirror your dependencies" workaround helped a lot, but I can only do that for direct dependencies. The major issue now as more Zig projects have adopted the build system and we've adopted more Zig deps are transitive dependencies.
Retries would help a lot here.
There is another issue I know tracking mirroring transitives. That'd be even better.
andrewrk commentedon Oct 26, 2025
That reminds me - one thing I noticed when reworking the DNS lookup code for #25592 is that DNS queries were never retried ever which is kind of a basic failure of using the UDP protocol. The "TemporaryNameServerFailure" error isn't even possible anymore in the reworked Linux code because it now retries properly (an amount configurable in /etc/resolv.conf).
I don't think that closes this issue entirely, but it does make me curious, did the problem happen on macOS or Windows, which use getaddrinfo from libc?
mitchellh commentedon Oct 26, 2025
I only noticed in CI, which is primarily Linux. We do run macOS as well and I don't recall those machines failing but memory is fallible...