Skip to content

fix: retry transient Windows file sharing violations - #4

Open
SultanGun wants to merge 1 commit into
mevarx:mainfrom
SultanGun:fix/windows-file-sharing-violations
Open

SultanGun wants to merge 1 commit into
mevarx:mainfrom
SultanGun:fix/windows-file-sharing-violations

Conversation

@SultanGun

Copy link
Copy Markdown
Contributor

Summary

This PR adds a platform-specific file-writing helper that retries transient Windows file-sharing violations when FilePatchTool and FileWriteTool write files.

Problem

On Windows, file-writing operations can intermittently fail with ERROR_SHARING_VIOLATION (Win32 error 32) during repeated read-and-write sequences. This can cause otherwise valid file operations and tests to fail intermittently.

Changes

  • Add a Windows-specific writeToolFile implementation with bounded retries for ERROR_SHARING_VIOLATION.
  • Use exponential backoff with up to five total attempts and delays of 2, 4, 8, and 16 milliseconds.
  • Return unrelated errors immediately without retrying.
  • Preserve the existing in-place write behavior.
  • Add a non-Windows implementation that delegates directly to os.WriteFile.
  • Add unit and integration tests covering retry behavior, error handling, and modification callback semantics.

Verification

Verified locally on Windows with Go 1.27.3:

  • gofmt -l .
  • go vet ./...
  • go test ./... -count=1
  • go test ./internal/tools -run "^TestWriteToolFile_" -v
  • Linux cross-compilation checks for the non-Windows implementation.

All listed checks passed in the reported local environment. Native macOS testing was not performed.

Scope

This PR focuses exclusively on the Windows file-writing fix and its tests. Fork-specific CI changes are intentionally excluded.

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.

1 participant