#20025: Fix Matrix messages silently dropped due to zero startup grace
channel: matrix
size: XS
trusted-contributor
Fixes #19843
`startupGraceMs` was hardcoded to 0, causing every incoming message to be dropped when the Matrix homeserver clock is even slightly behind the OpenClaw host. This is common in multi-machine setups (e.g. Pi running OpenClaw + separate Synapse server).
Changes:
- Bump grace period from 0 to 5 seconds to tolerate typical NTP skew
- Add debug-level logging when events are filtered, so operators can diagnose message delivery issues without patching the source
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes silent message dropping in the Matrix extension caused by a hardcoded `startupGraceMs = 0`. When the Matrix homeserver clock is even slightly behind the OpenClaw host (common in multi-machine setups like Pi + separate Synapse), every incoming message was filtered out. The grace period is now 5 seconds, and debug-level logging is added to the two event-filtering branches for easier diagnosis.
- `startupGraceMs` bumped from `0` to `5_000` in `extensions/matrix/src/matrix/monitor/index.ts`
- Debug log statements added to both pre-startup and stale-event filters in `extensions/matrix/src/matrix/monitor/handler.ts`
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it's a minimal, targeted fix with no risk of regression.
- The change is extremely small and well-scoped: a single constant change from 0 to 5000 and two debug log additions. The fix addresses a clear bug (zero grace period causing silent message drops). The 5-second grace period is a reasonable default for NTP skew. The debug logging is non-intrusive and aids future troubleshooting. No behavioral changes beyond the intended fix.
- No files require special attention.
<sub>Last reviewed commit: b4ada1c</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20278: Fix/matrix missing bot sdk dependency
by saurav470 · 2026-02-18
75.5%
#19294: fix: normalize room ID case in Matrix config lookup
by MisterGuy420 · 2026-02-17
73.1%
#10606: fix(matrix): keep room IDs without :server suffix as-is during reso...
by majorminors · 2026-02-06
72.7%
#7842: Fix Matrix mention detection for Element client (formatted_body links)
by emadomedher · 2026-02-03
71.5%
#20047: fix(googlechat): typing indicator shows 'OpenClaw' instead of agent...
by xinhuagu · 2026-02-18
71.0%
#2902: fix(matrix): check if requestOwnUserVerification exists before calling
by dokterdok · 2026-01-27
70.9%
#8852: fix(matrix): Await mxcToHttp to properly detect authenticated media...
by emadomedher · 2026-02-04
70.0%
#6517: fix(matrix): pass accountId through outbound chain to resolveMatrix...
by saxyguy81 · 2026-02-01
69.5%
#10313: fix(matrix): fallback to authenticated media download (Matrix v1.11+)
by iter-next · 2026-02-06
69.2%
#10721: fix for matrix media: destructure downloadContent return value in m...
by mklasen · 2026-02-06
68.9%