promote: run session keep-alive as a daemon tick (not a 24h timer) - #107
Merged
Merged
Conversation
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>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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+sessionRefreshRunningguard.Verified
tsc(app + worker) clean.🤖 Generated with Claude Code