Clock-skew warning: compare the homeserver Date header to the local clock and warn once when it is far off #158
Closed
opened 2026-09-17 22:53:32 -04:00 by jared
·
1 comment
No Branch/Tag Specified
lotus
update-packages
sw-fix
read-me-update
image-path-changes
dm-calls
fix-2469
renovate/element-hq-element-call-embedded-0.x
renovate/npm-i18next-http-backend-vulnerability
renovate/npm-vite-vulnerability
dev
docs-update
more-theme
fix-257
imporve-thread-reply
revert-2402-improve-menu-congestion
mxidColor-toggle
update-sw-main-msg
v4.11.1
v4.10.5
v4.10.4
v4.10.3
v4.10.2
v4.10.1
v4.10.0
v4.9.1
v4.9.0
v4.8.1
v4.8.0
v4.7.1
v4.7.0
v4.6.0
v4.5.1
v4.5.0
v4.4.0
v4.3.2
v4.3.0
v4.2.3
v4.2.2
v4.2.1
v4.2.0
v4.1.0
v4.0.3
v4.0.0
v3.2.0
v3.1.0
v3.0.0
v2.2.6
v2.2.5
v2.2.4
v2.2.3
v2.2.2
v2.2.1
v2.2.0
v2.1.3
v2.1.2
v2.1.1
v2.1.0
v2.0.4
v2.0.3
v2.0.2
v2.0.1
v2.0.0
v1.8.2
v1.8.1
v1.8.0
v1.7.0
v1.6.1
v1.6.0
v1.5.1
v1.5.0
v1.4.0
v1.3.2
v1.3.1
v1.3.0
v1.2.1
v1.2.0
v1.1.0
v1.0.0
Labels
Clear labels
a11y
area: appearance
area: auth-session
area: build-ci
area: calls
area: desktop
area: media
area: messaging
area: mobile
area: moderation
area: navigation
area: notifications
area: settings
area: threads
bug
dependencies
docs
duplicate
enhancement
help wanted
invalid
needs-human-review
performance
planning
priority: critical
priority: high
priority: low
priority: medium
qa
question
research
security
tech-debt
ux
wontfix
Accessibility: keyboard, screen reader, contrast, motion
Client area: appearance
Client area: auth-session
Client area: build-ci
Client area: calls
Client area: desktop
Client area: media
Client area: messaging
Client area: mobile
Client area: moderation
Client area: navigation
Client area: notifications
Client area: settings
Client area: threads
Something is not working
Third-party package versions and advisories
README / LOTUS_* docs wrong or missing
This issue or pull request already exists
New feature
Need some help
Something is wrong
Re-render storms, leaks, heavy work on hot paths
Data loss, security hole, or crash on a main path
Broken feature or serious usability problem
Minor issue or polish
Wrong behaviour in an edge case or notable degradation
Manual QA: shipped, needs a human in a real environment
More information is needed
XSS, unsafe URLs, data leaks, auth/session
Code health, dead code, fragile patterns
Usability or visual inconsistency
This won't be fixed
Milestone
No items
No Milestone
Features 2026-Q4
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: LotusGuild/cinny#158
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Incident 2026-09-17: a wrong Windows clock made every MatrixRTC call membership look expired locally (own membership "missing → force re-join", "No targets found for sending key", peers' media keys rejected) while Synapse was returning 200 for everything. Nothing in the UI hinted at the cause. Encryption (Olm/Megolm key validity, key backup), delayed events and LiveKit JWTs are all time-sensitive too.
Design ("done properly")
Dateresponse header from ordinary homeserver requests the client already makes (/sync,/versions) — no extra requests. Computeskew = Date.now() − serverDate − (roundTrip / 2)on a fast request only (RTT < 2 s) to avoid mistaking latency for skew; take the median of the last 3 samples before acting. Re-sample on startup and after each reconnect/SyncStatePREPARED.utils/clockSkew.ts(sample filtering, median, hysteresis, direction wording) unit-tested; the header parse tolerates a missing/invalid header (no warning, no throw).Shipped in
84c906fe, with one deliberate deviation from the design's measurement source:Measurement — not the
Dateheader. Synapse's CORS policy only exposesSynapse-Trace-Id, Server, ETag, soDateis unreadable from a different origin (chat. vs matrix.) without touching nginx. Instead every live event already carries the answer:origin_server_ts(origin server's stamp) +unsigned.age(OUR server'snow − tswhen it built the/syncresponse) = our server's clock at response time, and matrix-js-sdk already computeslocalTimestamp = Date.now() − ageat event construction, so a sample is justlocalTimestamp − origin_server_ts(download latency = tens of ms of noise;Datehas 1 s granularity anyway). No extra requests, no headers, no RTT filtering needed — and it works for federated events too, sinceageis always computed by our server. OnlyRoomEvent.Timelinelive events count; the SDK already flags cache replays (staleage) asliveEvent=false. The initial network sync qualifies, so a wrong clock is flagged within seconds of startup.Thresholds as designed: median of the last 5 samples (≥3), warn at |skew| > 30 s, clear below 15 s.
UI: banner in the sync-status slot with direction ("14 minutes ahead of the server" / "3 hours behind the server"), How to fix expands a per-OS one-liner (Windows/macOS/Linux/iOS/Android detected from the UA), Dismiss for 24 h (localStorage). Same line in the call status bar while in a call. Nothing is auto-corrected.


Verified headless with Playwright's clock skewed +14 min and −3 h (banner, hint, in-call line, dismiss) and in sync (nothing shown); 6 unit tests on the monitor and wording.