Skip to content

Refresh update check on page load when cache is stale - #9

Merged
veniplex merged 1 commit into
mainfrom
claude/github-update-notifications-6chwgt
Jul 13, 2026
Merged

veniplex merged 1 commit into
mainfrom
claude/github-update-notifications-6chwgt

Conversation

@veniplex

Copy link
Copy Markdown
Owner

Summary

Follow-up to #5. The daily cron (check-updates pg-boss job, 0 6 * * *) already keeps system.updateCheck fresh, so most page loads just read the cached setting — no outbound request.

As a backstop for when the cron missed its run (e.g. the server was down at 06:00), getUpdateStatus() now schedules one background GitHub check via Next.js's after() (runs after the response is sent, doesn't block the page) whenever the cached result is older than 20 hours. Concurrent requests during that window are deduped via an in-process in-flight guard, so several tabs/admins loading a page at once while the cache is stale only trigger one outbound request.

Net effect: on login or a full page reload, an admin sees a check that's at most ~20h old, refreshing itself in the background if it's gone stale — without hitting GitHub's API on every request.

Test plan

  • npx tsc --noEmit
  • npx eslint src/lib/update-check.ts
  • npx prettier --check src/lib/update-check.ts
  • Manual QA: with an old checkedAt in system.updateCheck, confirm a page load triggers exactly one refresh (check server logs / the setting's checkedAt updates)

Generated by Claude Code

The daily cron already keeps system.updateCheck fresh, so most page
loads just read the cached setting — no outbound request. As a
backstop for when the cron missed its run, getUpdateStatus() now
schedules one background GitHub check (via next/server's after(), so
it doesn't block the response) whenever the cached result is older
than 20 hours. Concurrent requests during that window are deduped via
an in-memory in-flight guard.
@veniplex veniplex added the release-candidate Creates a new release and deployment of docker image, once merged. label Jul 13, 2026
@veniplex
veniplex merged commit 3794e26 into main Jul 13, 2026
1 of 2 checks passed
@veniplex
veniplex deleted the claude/github-update-notifications-6chwgt branch July 13, 2026 17:04
github-actions Bot added a commit that referenced this pull request Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-candidate Creates a new release and deployment of docker image, once merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants