Repository navigation
gomod: retry module downloads that fail mid-stream - #71
Merged
Merged
Conversation
grouville
self-requested a review
October 21, 2026 19:03
grouville
approved these changes
Oct 21, 2026
proxy.golang.org sometimes resets a module zip download partway through
("read ... .zip: stream error: stream ID N; INTERNAL_ERROR; received from
peer"). With Go's default GOPROXY ("https://proxy.golang.org,direct")
only a 404 or 410 falls through to the next entry, so the build fails.
Set GOPROXY to "https://proxy.golang.org|https://proxy.golang.org|direct"
in withGoCaches, which every Go container here goes through, and in the
in-process scanner container. "|" falls through on any error, so a zip
download that fails mid-stream retries the proxy once and then fetches
from the origin. A container that sets a non-empty GOPROXY keeps it. The
existing go.sum and GOSUMDB verification policy is unchanged.
Signed-off-by: Erik Sipsma <[email protected]>
sipsma
force-pushed
the
goproxy-retry-mid-stream
branch
2 times, most recently
from
October 21, 2026 19:06
be35181 to
0e3a601
Compare
sipsma
added a commit
to sipsma/dagger
that referenced
this pull request
Oct 21, 2026
…retries The golang workspace module (generate and test checks) still used dagger/go's pull/45 head, which is frozen at its September merge. Pin it to the dagger/go main merge of dagger/go#71, which also contains dagger/go#72: - dagger/go#71 sets GOPROXY to proxy.golang.org|proxy.golang.org|direct in withGoCaches, so a module zip download that the proxy resets mid-stream is retried once against the proxy and, on another proxy failure, attempted directly from the origin. The check can still fail if that fallback fails. - dagger/go#72 speeds up package discovery. The source names a commit rather than main because dagger.lock pins are not applied in Cloud's remote-workspace sessions, so main would float in CI. The dagger/go main entry in dagger.lock is refreshed to the same commit with dagger lock update. dagger/go now organizes checks and generators by package, so their names change: golang/generate-all/stale becomes golang/packages/generate/stale, golang/test-all becomes golang/packages/tests/test, and the golang/generate-all generator becomes golang/packages/generate. Update the release instructions' generate step to the new generator name. Signed-off-by: Erik Sipsma <[email protected]>
sipsma
added a commit
to sipsma/dagger
that referenced
this pull request
Oct 21, 2026
…retries The golang workspace module (generate and test checks) still used dagger/go's pull/45 head, which is frozen at its September merge. Pin it to the dagger/go main merge of dagger/go#73, which also contains dagger/go#71 and dagger/go#72: - dagger/go#71 sets GOPROXY to proxy.golang.org|proxy.golang.org|direct in withGoCaches, so a module zip download that the proxy resets mid-stream is retried once against the proxy and, on another proxy failure, attempted directly from the origin. The check can still fail if that fallback fails. - dagger/go#72 and dagger/go#73 speed up and fix package discovery. The source names a commit rather than main because dagger.lock pins are not applied in Cloud's remote-workspace sessions, so main would float in CI. The dagger/go main entry in dagger.lock is refreshed to the same commit with dagger lock update. dagger/go now organizes checks and generators by package, so their names change: golang/generate-all/stale becomes golang/packages/generate/stale, golang/test-all becomes golang/packages/tests/test, and the golang/generate-all generator becomes golang/packages/generate. Update the release instructions' generate step to the new generator name. Signed-off-by: Erik Sipsma <[email protected]>
sipsma
added a commit
to sipsma/dagger
that referenced
this pull request
Oct 21, 2026
…retries The golang workspace module (generate and test checks) still used dagger/go's pull/45 head, which is frozen at its September merge. Pin it to the dagger/go main merge of dagger/go#73, which also contains dagger/go#71 and dagger/go#72: - dagger/go#71 sets GOPROXY to proxy.golang.org|proxy.golang.org|direct in withGoCaches, so a module zip download that the proxy resets mid-stream is retried once against the proxy and, on another proxy failure, attempted directly from the origin. The check can still fail if that fallback fails. - dagger/go#72 and dagger/go#73 speed up and fix package discovery. The source names a commit rather than main because dagger.lock pins are not applied in Cloud's remote-workspace sessions, so main would float in CI. The dagger/go main entry in dagger.lock is refreshed to the same commit with dagger lock update. dagger/go now organizes checks and generators by package, so their names change: golang/generate-all/stale becomes golang/packages/generate/stale, golang/test-all becomes golang/packages/tests/test, and the golang/generate-all generator becomes golang/packages/generate. Update the release instructions' generate step to the new generator name. Signed-off-by: Erik Sipsma <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What fails. proxy.golang.org sometimes resets a module zip download partway through:
read "https://proxy.golang.org/<module>/@v/<version>.zip": stream error: stream ID N; INTERNAL_ERROR; received from peer. In dagger/dagger's CI this shows up repeatedly (12 confirmed incidents plus 5 candidates on Oct 19-20), including ingolang/generate-allandgolang/test-all, which use this module.Why it fails.
https://proxy.golang.org,direct. Incmd/go, a zip body-read error happens insideTryProxies(src/cmd/go/internal/modfetch/fetch.go:304-325,proxy.go:418-440).,, only a 404 or 410 moves on to the next entry; after a|, any error does (proxy.go:50-58,179). So a reset fails the build.The change.
withGoCaches, which every Go container in this repo goes through (the default toolchain container, a caller'sbaseImage, per-directory containers, golangci-lint, staticcheck), now setsGOPROXY=https://proxy.golang.org|https://proxy.golang.org|directunless the container already has a non-empty GOPROXY.git, so an origin fetch of a VCS-hosted module may also fail there; the proxy retry is the main benefit.proxyListdoesn't deduplicate entries, so repeating the proxy is a supported way to get one retry.go.sum/GOSUMDB verification policy is unchanged.Evidence (through Dagger, on a dedicated engine):
gomod | with-go-caches <golang:1.26-alpine> | with-exec go env GOPROXYhttps://proxy.golang.org|https://proxy.golang.org|directGOPROXY=https://private.example.invalid|offhttps://private.example.invalid|offdagger checkThe same
|mechanism was demonstrated with a fault-injecting proxy in dagger/dagger #14750:,fails withread "…zip": unexpected EOF, while the repeated-proxy form retries and succeeds.Cost and limits.
withGoCachesnow reads the caller container's GOPROXY, which resolves that container's metadata. If that lookup fails, the error propagates (the call fails) rather than being ignored..info/.modlookups, whose errors are cached per proxy and module.directadds VCS, network, auth and rate-limit exposure where it applies.go-mod/go-buildcache volumes stay reusable.Reaching dagger/dagger.
dagger.tomlhas[modules.golang] source = "dagger.io/go@pull/45/head". Select generation by directory #45 is merged and its head is frozen at a Sep 15 commit (also thedagger.lockpin), so this change has no effect there by itself.@mainor a SHA) plus a lock refresh.pull/45/headalso adopts every dagger/go change since Sep 15, not just this one.