Fix provider cache atomic write temp path collisions#2291
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
ApprovabilityVerdict: Approved This PR extracts duplicate atomic file write logic into a shared utility and improves temp file path generation to use UUIDs instead of pid+timestamp, addressing potential collision issues. The changes are mechanical consolidation with a minor reliability improvement, self-contained with no API or schema changes. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com> (cherry picked from commit e25db3a)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
What Changed
Why
Provider cache writes used temp filenames derived from
process.pidandDate.now(). Two writes to the same cache file in the same process and same millisecond could pick the same temp path, causing onerename()to move the file and the other to fail withENOENT. The helper now creates a scoped temp directory beside the target file and writes a UUID-named temp file before the final atomic rename, removing that collision class while keeping the implementation inside Effect APIs.Checklist
Note
Fix temp path collisions in provider cache atomic writes by extracting
writeFileStringAtomicallywriteFileStringAtomicallyutility that writes to a UUID-named temp file in a scoped temp directory co-located with the target, then renames it to the final path.Macroscope summarized 6ad9e56.