{{ message }}
Repository navigation
Tags: jetify-com/devbox
Tags
fix(nix): retry nix commands that fail with transient network errors (#… …2995) ## Summary In nightly run [37286584167](https://github.com/jetify-com/devbox/actions/runs/37286584167), `test-nix-versions (macos-latest, 2.30.2)` failed because a nixpkgs tarball download got cut off during `nix print-dev-env`: ``` unpacking 'github:NixOS/nixpkgs/104240a7…' into the Git cache... error: cannot read file from tarball: Truncated tar archive detected while reading data ``` Nix retries failed downloads, but not ones that fail partway through unpacking. Users can hit this too, not just CI, so devbox now retries these errors itself. ## Changes - `nix.Cmd` has a new `MaxAttempts` field, defaulted from the new `nix.Nix.MaxAttempts`. If a command fails and its stderr matches a known transient error, devbox re-runs it with a short backoff (2s, then 4s) and prints one line explaining why. The transient errors are: - truncated or damaged tarballs - connection reset by peer - curl `Failure when receiving data from the peer` and `Timeout was reached` - `HTTP error 500/502/503/504` - Devbox sets `Default.MaxAttempts = 3` in `internal/nix`. The zero value keeps today's behavior for other users of the public `nix` package. - Where stderr is read from: - `Output`: the exit error, which covers `print-dev-env`, `eval`, `path-info`, and similar. - `CombinedOutput`: the combined output. - `Run` with a caller-provided stderr, like `nix build`: the last 8 KiB, copied off as it streams to the caller's writer. - Cases that are deliberately not retried: - **Stderr is a terminal.** Nix's output passes straight through so its progress bar still renders. Interactive `nix build` won't retry, but `print-dev-env` will. Non-TTY environments like CI retry both. - **Stdin isn't a file.** The first attempt may have consumed it. - **GitHub rate limits (403/429) and DNS failures.** These won't clear within a few seconds, and retrying would only slow down offline use. ## Test plan - [x] New tests in `nix/command_test.go` use a fake `nix` script and cover: - retry then success for `Output`, `CombinedOutput`, and `Run` with a teed stderr - giving up after `MaxAttempts` - no retry for non-transient errors, a 403, retries disabled, and non-file stdin - stopping when the context is cancelled during the backoff - [x] `go test -race ./nix/`, `go test ./internal/nix/...`, and `golangci-lint` all pass - [x] Ran `devbox install` and `devbox run` against real Nix with a locally built binary, with stderr piped so the teed path ran - [x] CI 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fix(nix): retry nix commands that fail with transient network errors (#… …2995) ## Summary In nightly run [37286584167](https://github.com/jetify-com/devbox/actions/runs/37286584167), `test-nix-versions (macos-latest, 2.30.2)` failed because a nixpkgs tarball download got cut off during `nix print-dev-env`: ``` unpacking 'github:NixOS/nixpkgs/104240a7…' into the Git cache... error: cannot read file from tarball: Truncated tar archive detected while reading data ``` Nix retries failed downloads, but not ones that fail partway through unpacking. Users can hit this too, not just CI, so devbox now retries these errors itself. ## Changes - `nix.Cmd` has a new `MaxAttempts` field, defaulted from the new `nix.Nix.MaxAttempts`. If a command fails and its stderr matches a known transient error, devbox re-runs it with a short backoff (2s, then 4s) and prints one line explaining why. The transient errors are: - truncated or damaged tarballs - connection reset by peer - curl `Failure when receiving data from the peer` and `Timeout was reached` - `HTTP error 500/502/503/504` - Devbox sets `Default.MaxAttempts = 3` in `internal/nix`. The zero value keeps today's behavior for other users of the public `nix` package. - Where stderr is read from: - `Output`: the exit error, which covers `print-dev-env`, `eval`, `path-info`, and similar. - `CombinedOutput`: the combined output. - `Run` with a caller-provided stderr, like `nix build`: the last 8 KiB, copied off as it streams to the caller's writer. - Cases that are deliberately not retried: - **Stderr is a terminal.** Nix's output passes straight through so its progress bar still renders. Interactive `nix build` won't retry, but `print-dev-env` will. Non-TTY environments like CI retry both. - **Stdin isn't a file.** The first attempt may have consumed it. - **GitHub rate limits (403/429) and DNS failures.** These won't clear within a few seconds, and retrying would only slow down offline use. ## Test plan - [x] New tests in `nix/command_test.go` use a fake `nix` script and cover: - retry then success for `Output`, `CombinedOutput`, and `Run` with a teed stderr - giving up after `MaxAttempts` - no retry for non-transient errors, a 403, retries disabled, and non-file stdin - stopping when the context is cancelled during the backoff - [x] `go test -race ./nix/`, `go test ./internal/nix/...`, and `golangci-lint` all pass - [x] Ran `devbox install` and `devbox run` against real Nix with a locally built binary, with stderr piped so the teed path ran - [x] CI 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ci: replace unmaintained github-tag-action with plain git tag/push (#… …2887) ## Summary The edge release job only used `mathieudutour/github-tag-action` to create and push a pre-computed tag (`EDGE_TAG`), not its semver auto-bump feature. That action is unmaintained (last release Mar 2024) and runs on the soon-to-be-deprecated Node 20, so this replaces it with two plain `git` commands that do exactly what was being used. The existing `contents: write` permission and default `GITHUB_TOKEN` from checkout cover pushing the tag, and the step's outputs weren't referenced elsewhere. ## How was it tested? Static review of the workflow — the change is a no-op on behavior, swapping the action for the equivalent `git tag`/`git push` it was performing. The full edge release path runs on the weekly schedule / manual dispatch. ## Community Contribution License All community contributions in this pull request are licensed to the project maintainers under the terms of the [Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0). By creating this pull request, I represent that I have the right to license the contributions to the project maintainers under the Apache 2 License as stated in the [Community Contribution License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license). --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PreviousNext
