Skip to content

promote: run session keep-alive as a daemon tick (not a 24h timer) - #107

Merged
ralyodio merged 1 commit into
masterfrom
promote/session-daemon
Jul 17, 2026
Merged

ralyodio merged 1 commit into
masterfrom
promote/session-daemon

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Why

Follow-up to #106. The worker process is already a long-running daemon, but I'd scheduled the session keep-alive as setInterval(24h) — a 24-hour timer resets on every deploy/restart, so on a platform that redeploys more than once a day it would almost never fire, leaving the whole cadence resting on the one startup run.

Change

Make it a frequent daemon tick (every 30 min), matching every other worker sweep (audits, promote, uptime). The sweep's 23h per-account gate (session_refreshed_at) still enforces the once-a-day cadence — but now it's restart-proof: whichever tick lands after an account crosses 23h re-warms it. Added a re-entrancy guard so slow browser runs never overlap. Most ticks are a cheap no-op (nothing due).

  • worker/index.ts — SESSION_REFRESH_TICK_MS = 30min + sessionRefreshRunning guard.

Verified

tsc (app + worker) clean.

🤖 Generated with Claude Code

The worker is already a long-running daemon, but the session keep-alive was a
setInterval(24h) — a day-long timer resets on every deploy/restart, so it would
almost never fire and the cadence leaned entirely on the startup run. Make it a
frequent daemon tick (every 30 min) like the other worker sweeps; the sweep's
23h per-account DB gate (session_refreshed_at) still makes each account refresh
about once a day, but now it's restart-proof — whatever tick lands after an
account crosses 23h re-warms it. Added a re-entrancy guard so slow (browser)
runs never overlap. Most ticks find nothing due and are a cheap no-op query.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio
ralyodio merged commit b2056d6 into master Jul 17, 2026
8 checks passed
@ralyodio
ralyodio deleted the promote/session-daemon branch July 17, 2026 11:01
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