Skip to content

fix: clear empty version-cache lock when update fetch fails#30

Merged
daniel3303 merged 1 commit into
mainfrom
fix/version-cache-empty-stampede-lock
Apr 23, 2026
Merged

fix: clear empty version-cache lock when update fetch fails#30
daniel3303 merged 1 commit into
mainfrom
fix/version-cache-empty-stampede-lock

Conversation

@daniel3303
Copy link
Copy Markdown
Owner

Summary

The update-check code touches statusline-version-cache.json before calling the GitHub API as a stampede lock — so N concurrent status-line renders don't all fire the request in parallel. If the fetch fails (network blip, rate limit, 5-second timeout, or — as happened today — the first render that ran in the narrow window between deleting the cache and the release actually appearing on GitHub), the touched file stays on disk at zero bytes with a fresh mtime. The 24-hour TTL check then sees a "fresh" cache and suppresses every update check for a full day, even though no data was ever written.

Code changes

  • statusline.sh:463-477 — After a failed curl, if the cache file is empty (! -s), rm -f it so the next render retries instead of waiting 24h.
  • statusline.ps1:432-452 — Mirror fix: in the catch, if the cache file exists and has Length -eq 0, Remove-Item it.

Success path is unchanged; if the cache pre-existed with valid content and the fetch fails, the old content is kept and reused (stale-but-usable fallback), retrying on the normal 24h boundary.

How to test

  1. Delete the cache file: rm /tmp/claude/statusline-version-cache.json (macOS/Linux) or the Windows equivalent under $env:TEMP\claude\.
  2. Temporarily block the API (e.g. point to a bogus host in the script, or disconnect the network) and run the script once.
  3. Confirm the cache file is not left behind as a zero-byte file.
  4. Restore the API, run the script, confirm the cache fills normally and the Update available: … line surfaces when VERSION is behind the latest GitHub release.

@daniel3303 daniel3303 merged commit ded3a74 into main Apr 23, 2026
@daniel3303 daniel3303 deleted the fix/version-cache-empty-stampede-lock branch April 23, 2026 16:21
The update check touches the version-cache file before calling the
GitHub API so concurrent status-line renders don't all issue the
request in parallel. If the fetch fails (network blip, rate limit,
5s timeout), the touched file is left on disk at zero bytes with a
fresh mtime, and the 24h TTL then suppresses every subsequent update
check for a full day even though no data was ever cached. Drop the
empty lock in the failure path so the next render retries.
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