Add a warning log and more comments

This commit is contained in:
Tulir Asokan 2022-06-30 14:46:46 +03:00
parent 44768c9c93
commit 2542f94e00
2 changed files with 4 additions and 0 deletions

View file

@ -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.

View file

@ -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)