Skip to content

Fix TestBuildHermeticEnv cleanup race with Go telemetry background process - #284

Draft
mohammed90 with Copilot wants to merge 1 commit into
dependabot/github_actions/actions/setup-go-7from
copilot/fix-failing-test-github-actions
Draft

Fix TestBuildHermeticEnv cleanup race with Go telemetry background process#284
mohammed90 with Copilot wants to merge 1 commit into
dependabot/github_actions/actions/setup-go-7from
copilot/fix-failing-test-github-actions

Conversation

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

TestBuildHermeticEnv fails intermittently on Go 1.26 Linux with TempDir RemoveAll cleanup: unlinkat .../telemetry: directory not empty. Go's telemetry subsystem spawns a background OS process that continues writing to $HOME/.config/go/telemetry/ after go mod init exits, racing against t.TempDir's RemoveAll cleanup.

Fix

Pre-create the telemetry mode file before running the hermetic build:

telemetryDir := filepath.Join(homeDir, ".config", "go", "telemetry")
os.MkdirAll(telemetryDir, 0o755)
os.WriteFile(filepath.Join(telemetryDir, "mode"), []byte("off\n"), 0o644)

Setting the mode to off prevents the background telemetry process from starting. GOTELEMETRY is not an overridable OS env var—it is read from this mode file—so this is the correct mechanism.

Fails only on Linux/Go 1.26 because macOS resolves the telemetry dir via ~/Library/... (outside the hermetic HOME), and the race window is narrower on earlier Go versions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants