You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auth key stays listed as active after expiring it when the browser clock is behind #703
After expiring an auth key on Settings → Auth keys, the key often stays in the list as active, still showing its Expire button, even though Headscale has expired it. Reloading a little later shows it as expired.
Headscale sets an expired key's expiration to its own current time. The page then decides whether a key is past its expiry by comparing that timestamp with the browser's clock (new Date(key.expiration) < new Date() in overview.tsx and auth-key-row.tsx). If the browser's clock is even slightly behind the Headscale server's, the just-expired key still counts as active, and nothing re-renders it once that moment passes.
To reproduce, with the browser's clock about 2 seconds behind the server:
Open Settings → Auth keys and clear the status filter.
Expire an active key.
The row shows Expires: now and keeps its Expire button.
Seen on Headplane 0.8.2 against Headscale 0.29.8, and reproduced on main (4d97ffd) against Headscale 0.29.5 using the test harness, with the browser's clock set 2 seconds behind.
A fix would decide expiry on the server, in the loader, where the clock matches the one Headscale used when Headplane and Headscale share a host or keep their clocks in sync.
Actionable. The root cause is as described: the auth keys page decides expiry with the browser's clock in two places.
app/routes/settings/auth-keys/overview.tsx (the status filter) compares new Date(key.expiration) < new Date().
app/routes/settings/auth-keys/auth-key-row.tsx compares expiration < new Date() for the Expired label and to hide the Expire button.
Headscale stamps an expired key's expiration with its own time.Now(), so a browser clock even slightly behind still sees the key as unexpired. The row never updates because the browser clock never crosses that timestamp. Reloading only helps once the browser clock catches up.
#704 ("fix(ui): decide auth key expiry on the server") is open against main at 4d97ffd and implements exactly the approach this issue describes. It is mergeable; at the time of writing the build, unit, and version-independent integration jobs pass, and the 0.27.1/0.28.0/0.29.5 integration jobs plus the Nix check are still running. No separate implementation is needed unless review asks for changes.
Wait for the integration matrix to pass on 0.27.1, 0.28.0, and 0.29.5. The loader path differs by version (listAll on 0.28+, per-user fetches on 0.27), so all three matter.
Confirm the changelog line sits under ## Fixes and reads as prose for operators.
Decide whether to handle no-expiry keys in the same change or as a follow-up (see below).
Edge cases and follow-ups
No-expiry keys: Headscale returns 0001-01-01T00:00:00Z for a key created without an expiration (the contract test a key without an expiration gets the zero time covers this). fix(ui): decide auth key expiry on the server #704's comparison marks those keys expired, which is the page's current behavior, not a regression. A proper fix would use isNoExpiry() from app/utils/node-info.ts and render Never in the Expires cell. That is a separate bug worth its own issue unless the reviewer wants it here.
Natural expiry while the page is open: the loader flag is a snapshot. A key that expires after the page loads stays active until a revalidation; the live store will not fire because the expiration field does not change. This limitation predates the fix and can be a follow-up if it matters.
Headplane ↔ Headscale clock skew: the fix assumes the Headplane server clock is at or ahead of Headscale's, as the issue notes. If Headplane's clock is behind, the same symptom can occur server-side. The <= comparison helps at the exact boundary but not with real skew, and Headscale exposes no server-time source to correct against.
Test coverage: the integration test locks in the server decision. A component test for the row would need a data router and Base UI; the PR's manual harness check with a browser clock 2 seconds behind covers that wiring, which is consistent with this repo's testing bar.
Verification
pnpm test:unit
pnpm vitest run --project integration:app tests/integration/headplane/auth-keys.test.ts (needs Docker)
pnpm run typecheck
pnpm run lint
pnpm run format or pnpm exec oxfmt --check <changed paths>
Manual: pnpm harness up <scenario> --headplane with the browser clock set behind the server, then expire a key and confirm the row reads Expired just now with no Expire button.
Activity
pullfrog commentedon Dec 2, 2026
Assessment
Actionable. The root cause is as described: the auth keys page decides expiry with the browser's clock in two places.
app/routes/settings/auth-keys/overview.tsx(the status filter) comparesnew Date(key.expiration) < new Date().app/routes/settings/auth-keys/auth-key-row.tsxcomparesexpiration < new Date()for the Expired label and to hide the Expire button.Headscale stamps an expired key's
expirationwith its owntime.Now(), so a browser clock even slightly behind still sees the key as unexpired. The row never updates because the browser clock never crosses that timestamp. Reloading only helps once the browser clock catches up.Status: already fixed by #704
#704 ("fix(ui): decide auth key expiry on the server") is open against
mainat4d97ffdand implements exactly the approach this issue describes. It is mergeable; at the time of writing the build, unit, and version-independent integration jobs pass, and the 0.27.1/0.28.0/0.29.5 integration jobs plus the Nix check are still running. No separate implementation is needed unless review asks for changes.What #704 changes
overview.tsxloader: takesnow = Date.now()on the server and annotates every key withexpired: new Date(key.expiration).getTime() <= now.overview.tsxcomponent: the status filter readskey.expiredinstead of the browser clock, so the default Active view also drops a just-expired key.auth-key-row.tsx: readsauthKey.expiredfor the label and the Expire button instead of callingnew Date().tests/integration/headplane/auth-keys.test.ts: expires a key, then asserts the loader lists it as expired. It fails before the change.CHANGELOG.md: one user-facing line under# Next→## Fixes.Milestones
PreAuthKey & { expired: boolean }), including theuserOptionstype guard inoverview.tsx.listAllon 0.28+, per-user fetches on 0.27), so all three matter.## Fixesand reads as prose for operators.Edge cases and follow-ups
0001-01-01T00:00:00Zfor a key created without an expiration (the contract testa key without an expiration gets the zero timecovers this). fix(ui): decide auth key expiry on the server #704's comparison marks those keys expired, which is the page's current behavior, not a regression. A proper fix would useisNoExpiry()fromapp/utils/node-info.tsand render Never in the Expires cell. That is a separate bug worth its own issue unless the reviewer wants it here.expirationfield does not change. This limitation predates the fix and can be a follow-up if it matters.<=comparison helps at the exact boundary but not with real skew, and Headscale exposes no server-time source to correct against.Verification
pnpm test:unitpnpm vitest run --project integration:app tests/integration/headplane/auth-keys.test.ts(needs Docker)pnpm run typecheckpnpm run lintpnpm run formatorpnpm exec oxfmt --check <changed paths>pnpm harness up <scenario> --headplanewith the browser clock set behind the server, then expire a key and confirm the row reads Expired just now with no Expire button.Task list (4/4 completed)
deepseek-v4.1-flash-1017(free via Pullfrog for OSS) | 𝕏linear-code commentedon Dec 2, 2026
HP-621