mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-05-21 07:22:44 +00:00
* fix: treat zero-byte lock file as stale to prevent permanent busy state If the HUD process crashes between fs.openSync(lockPath, 'wx') and fs.writeFileSync(fd, timestamp), a 0-byte .usage-cache.lock remains. readLockTimestamp() returns null for unparseable content, and the existing guard (lockTimestamp != null && expired) never fires, leaving the cache permanently stuck in 'busy' state. Add a lockTimestamp === null guard that uses fs.statSync().mtimeMs to distinguish a crash leftover (old mtime → remove and retry) from an active writer that is between openSync and writeFileSync (recent mtime → return busy). The original != null stale-timestamp path is unchanged. Closes #202 * test: stabilize stale-lock regression coverage * test: make usage-api suite self-build for source-only PRs --------- Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>