From fc1cfaa4617c6d64d612acc2a9441f19a644de70 Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Tue, 27 Oct 2026 21:46:15 -0400 Subject: [PATCH] build/test: default GOPROXY to proxy.golang.org|direct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit proxy.golang.org intermittently drops module zips mid-download (`stream error: … INTERNAL_ERROR; received from peer`), failing pantry builds that a rerun then fixes. The build and test scripts run with a cleared env, so a GOPROXY set in CI never reached them. Default GOPROXY to `https://proxy.golang.org|direct`: the `|` separator falls back to fetching from the module's source on any proxy error (`,` only falls back on 404/410). Modules fetched direct are still verified against go.sum and sum.golang.org. GOPROXY is also on the pass-through list, so a caller's value overrides the default. Exercised locally with `bk` on charm.sh/gum (build, test, audit): - caller GOPROXY=http://127.0.0.1:1 fails (override reaches go) - caller GOPROXY='http://127.0.0.1:1|direct' builds (fallback works) - GOPROXY unset builds and tests normally `deno test` has the same 5 local failures with and without the change. Co-Authored-By: Claude Opus 5.5 --- build/build.ts | 6 +++++- test/test.ts | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build/build.ts b/build/build.ts index ac6e0030..1c603886 100755 --- a/build/build.ts +++ b/build/build.ts @@ -111,7 +111,10 @@ await gum('build') const env: Record = { PATH: '/usr/bin:/bin:/usr/sbin:/sbin', - PKGX_DIR: useConfig().prefix.string + PKGX_DIR: useConfig().prefix.string, + // proxy.golang.org drops downloads mid-stream (`stream error … INTERNAL_ERROR`); + // `|` falls back to fetching from source on any error, `,` only on 404/410 + GOPROXY: 'https://proxy.golang.org|direct' } // compute sanitized `env` the script will run within @@ -120,6 +123,7 @@ for (const key of [ 'PKGX_PANTRY_PATH', // otherwise we cannot build against the user’s pantry 'PKGX_PANTRY_DIR', // otherwise we cannot build against the user’s pantry - v2 'GITHUB_TOKEN', // pass through for `gh` and that sort of thing + 'GOPROXY', // the caller’s choice wins over the default above 'LANG', 'LOGNAME', 'USER', 'TERM' // prevent POSIX tools from breaking ]) { const value = Deno.env.get(key) diff --git a/test/test.ts b/test/test.ts index 38ac6589..3ab0a6d1 100755 --- a/test/test.ts +++ b/test/test.ts @@ -88,9 +88,10 @@ await gum("test") const env: Record = { PATH: '/usr/bin:/bin:/usr/sbin:/sbin', - PKGX_DIR: useConfig().prefix.string + PKGX_DIR: useConfig().prefix.string, + GOPROXY: 'https://proxy.golang.org|direct' // see build.ts } -for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'PKGX_PANTRY_DIR', 'GITHUB_TOKEN', 'LANG', 'LOGNAME', 'USER', 'TERM']) { +for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'PKGX_PANTRY_DIR', 'GITHUB_TOKEN', 'GOPROXY', 'LANG', 'LOGNAME', 'USER', 'TERM']) { const value = Deno.env.get(key) if (value) env[key] = value }