Skip to content

fix: cache index update is non-atomic — partial failure leaves index inconsistent #398

@justn-hyeok

Description

@justn-hyeok

Description

packages/shared/src/utils/cache.ts writes the cache data file and then updates the index file in two separate writeFile calls. If the process is interrupted (crash, SIGKILL) between the two writes, or if the index write fails, the index no longer reflects the actual cache contents. Subsequent reads may return stale or missing entries while the data file is orphaned.

Location

packages/shared/src/utils/cache.ts

Expected Fix

Write to a temp file then rename() (atomic on POSIX), or write both files and verify. At minimum, catch index write failures and invalidate/remove the data entry to keep them consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions