fix: use server-computed endsAt for exploration timer to prevent clock drift #68

Merged
naomi merged 1 commits from fix/exploration-timer-drift into main 2026-03-18 17:09:48 -07:00
Owner

Summary

  • Exploration timers showed more time than the area's stated duration when the server clock was ahead of the client's
  • The timer was derived from startedAt = endsAt - durationMs, then computed as durationSeconds - (clientNow - startedAt) / 1000 — any server/client clock skew directly inflated the result
  • Now stores endsAt (the server-computed completion timestamp) directly in ExplorationAreaState and computes the timer as (endsAt - Date.now()) / 1000, which is immune to clock drift
  • Old saves without endsAt fall back gracefully to the previous startedAt-based calculation

Test plan

  • Start a new exploration — timer should show exactly the area's stated duration (no more "1h area shows 1h15m")
  • Refresh the page mid-exploration — timer should resume from the correct remaining time (using server-anchored endsAt)
  • Old saves with startedAt but no endsAt should still display a timer via the fallback path

Closes #53

This PR was created with help from Hikari~ 🌸

## Summary - Exploration timers showed more time than the area's stated duration when the server clock was ahead of the client's - The timer was derived from `startedAt = endsAt - durationMs`, then computed as `durationSeconds - (clientNow - startedAt) / 1000` — any server/client clock skew directly inflated the result - Now stores `endsAt` (the server-computed completion timestamp) directly in `ExplorationAreaState` and computes the timer as `(endsAt - Date.now()) / 1000`, which is immune to clock drift - Old saves without `endsAt` fall back gracefully to the previous `startedAt`-based calculation ## Test plan - [ ] Start a new exploration — timer should show exactly the area's stated duration (no more "1h area shows 1h15m") - [ ] Refresh the page mid-exploration — timer should resume from the correct remaining time (using server-anchored `endsAt`) - [ ] Old saves with `startedAt` but no `endsAt` should still display a timer via the fallback path Closes #53 ✨ This PR was created with help from Hikari~ 🌸
hikari added 1 commit 2026-03-18 16:47:03 -07:00
fix: use server-computed endsAt for exploration timer to prevent clock drift
CI / Lint, Build & Test (pull_request) Successful in 1m10s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m10s
53eaebd7d8
Exploration timers were showing more time than the area's stated duration
when the server clock was ahead of the client clock. The timer now uses
the server-provided endsAt timestamp directly instead of deriving startedAt
from it, making countdowns immune to client/server clock skew. Old saves
without endsAt fall back to the previous startedAt-based calculation.

Closes #53
naomi merged commit cfcf763ce3 into main 2026-03-18 17:09:48 -07:00
naomi deleted branch fix/exploration-timer-drift 2026-03-18 17:09:48 -07:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nhcarrigan/elysium#68