From 2542f94e00545a44d8d06e20e5e28dd2b8362693 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 30 Jun 2022 14:46:46 +0300 Subject: [PATCH] Add a warning log and more comments --- example-config.yaml | 2 ++ portal.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/example-config.yaml b/example-config.yaml index c431ba2..271859a 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -284,8 +284,10 @@ bridge: # Null means there's no enforced timeout. message_handling_timeout: # Send an error message after this timeout, but keep waiting for the response until the deadline. + # This is counted from the origin_server_ts, so the warning time is consistent regardless of the source of delay. error_after: 10s # Drop messages after this timeout. They may still go through if the message got sent to the servers. + # This is counted from the time the bridge starts handling the message. deadline: 60s # The prefix for commands. Only required in non-management rooms. diff --git a/portal.go b/portal.go index e0b0193..0bae64e 100644 --- a/portal.go +++ b/portal.go @@ -3156,6 +3156,8 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event) { if remainingTime < 0 { go ms.sendMessageMetrics(evt, fmt.Errorf("%w (message is %s old)", errTimeoutBeforeHandling, messageAge), "Timeout handling", true) return + } else if remainingTime < 1*time.Second { + portal.log.Warnfln("Message %s was delayed before reaching the bridge, only have %s (of %s timeout) until delay warning", evt.ID, remainingTime, portal.bridge.Config.Bridge.MessageHandlingTimeout.ErrorAfter) } go func() { time.Sleep(remainingTime)