This repository was archived by the owner on May 13, 2026. It is now read-only.
fix(system-status): return seconds-since-start, not epoch, for uptime - #939
Merged
Conversation
`/api/system/status.uptime` was being computed as
`SystemTime::now() - UNIX_EPOCH`, which is a Unix timestamp (~1.78e9),
not an uptime. Any UI rendering "uptime" from this field showed ~56
years.
`/api/health` already had the right pattern: a process-global
`SERVER_START: OnceLock<Instant>` recorded once in `FoldHttpServer::run`
via `mark_server_start()`, and `SERVER_START.elapsed().as_secs()` at
read time. This change extracts that read into a new
`pub fn server_uptime_secs() -> u64` next to `mark_server_start`, has
both `health_check` and `get_system_status` consume it, and adds a
regression test asserting the system-status `uptime` field is below
1_000_000 (a fresh test process is alive for at most a few seconds, so
the bound is generous; an epoch reintroduction would trip it
immediately).
Wire shape and field name unchanged — frontend keeps consuming
`uptime: number`.
Before:
curl /api/system/status -> {..., "uptime": 1778285378, ...}
After:
curl /api/system/status -> {..., "uptime": 5, ...}
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
shiba4life
enabled auto-merge
May 9, 2026 01:16
Pure rustfmt, no behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
/api/system/status.uptimewas returningSystemTime::now() - UNIX_EPOCH— a Unix timestamp (~1.78e9), not an uptime. Any UI rendering "uptime" from that field showed ~56 years./api/healthalready had the right pattern: a process-globalSERVER_START: OnceLock<Instant>recorded once inFoldHttpServer::runviamark_server_start(), then read withSERVER_START.elapsed().as_secs(). This PR extracts that read into a newpub fn server_uptime_secs() -> u64next tomark_server_start(so the two endpoints can't drift), and replaces theSystemTimearithmetic insrc/handlers/system.rswith the helper.Wire shape and field name unchanged — the frontend continues consuming
uptime: number.Before / after
Regression guard
test_system_statusnow reads the response body and assertsuptime < 1_000_000. A fresh test process is alive for at most a few seconds, so the bound is generous, while an epoch reintroduction (~1.78e9) would trip it instantly.Test plan
cargo build --workspacecleancargo clippy --workspace --all-targetsno new warnings (only pre-existingapple_import.rs build_attendee_ingestion_recordsmacOS-only dead-code warning, not exercised in Linux CI)cargo test --workspace --tests system_statuspasses including the new bound assertionOut of scope
uptimeJSON field name kept as-is (frontend dependency)/api/healthleft untouchedSystemStatusResponseshape unchanged🤖 Generated with Claude Code