Skip to content

Retry packages when wp.org API returns stale version data#70

Merged
retlehs merged 2 commits intomainfrom
fix/retry-stale-api-sync
Mar 26, 2026
Merged

Retry packages when wp.org API returns stale version data#70
retlehs merged 2 commits intomainfrom
fix/retry-stale-api-sync

Conversation

@retlehs
Copy link
Copy Markdown
Member

@retlehs retlehs commented Mar 26, 2026

Summary

  • Compare fetched versions_json against existing DB value after each API fetch
  • If unchanged and within 24-hour retry window: keep package dirty for next run
  • If unchanged and window expired: advance last_synced_at (non-version change)
  • If changed: advance last_synced_at normally
  • Log counters stale_retried / stale_expired in both update logs and sync run stats

Context

Race condition: SVN commit detected → pipeline fetches wp.org API → API returns cached/stale data → last_synced_at advanced → package never retried. Real example: woocommerce-germanized 4.0.0 was tagged and confirmed on the API at 2026-03-26 8:29am GMT, but our pipeline synced 2 minutes later with stale data (3.20.7) and stayed stuck for 6+ hours.

A one-time ./wppackages update --force should be run after deploy to heal any currently stuck packages.

🤖 Generated with Claude Code

When the SVN changelog flags a package as changed but the wp.org API
returns cached data (versions_json unchanged), keep the package dirty
for up to 24 hours after last_committed. After the retry window
expires, advance last_synced_at to prevent infinite retries from
non-version SVN changes (readme, assets, etc.).

Adds stale_retried and stale_expired counters to update logs and
sync run stats.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@retlehs retlehs self-assigned this Mar 26, 2026
Extract shouldAdvanceSyncedAt into a testable function with explicit
syncAdvance/syncRetry/syncExpire return values. Add tests covering
versions changed, unchanged within window, unchanged after window,
nil last_committed, and boundary conditions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@retlehs retlehs merged commit 107cbf3 into main Mar 26, 2026
5 checks passed
@retlehs retlehs deleted the fix/retry-stale-api-sync branch March 26, 2026 15:13
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