Prevent local cache overwrite races #1

Merged
stephen merged 1 commit from fix-local-cache-race into main 2026-06-08 05:11:32 +00:00
Owner

The local backend could overwrite an existing cache object if another job saved the same key after the preflight exists check but before publish. That breaks the save semantics, which expect a competing writer to become a benign cache conflict.

This changes local publish to copy into a unique temporary file, then link it into place as the atomic publish step. If the destination already exists, the backend raises CacheConflictError so the save layer skips the race just like the S3 backend.

Tests run:

  • npm test
  • npm run check
The local backend could overwrite an existing cache object if another job saved the same key after the preflight exists check but before publish. That breaks the save semantics, which expect a competing writer to become a benign cache conflict. This changes local publish to copy into a unique temporary file, then link it into place as the atomic publish step. If the destination already exists, the backend raises CacheConflictError so the save layer skips the race just like the S3 backend. Tests run: - npm test - npm run check
Prevent local cache overwrite races
All checks were successful
test / unit (pull_request) Successful in 22s
test / e2e (pull_request) Successful in 5s
test / e2e-post-save (pull_request) Successful in 4s
a19077514c
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rasterstate/cache-action!1
No description provided.