From 9ae57cd9ab22d3a5fcc603c02ed4e9bc2b1fdc9a Mon Sep 17 00:00:00 2001 From: boreq Date: Thu, 30 Nov 2023 16:52:21 +0100 Subject: [PATCH] Lower timeout when pushing events to relay.nos.social It is pointless to wait more than a couple of seconds if something is wrong. --- service/app/handler_process_saved_event.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service/app/handler_process_saved_event.go b/service/app/handler_process_saved_event.go index a9d6357..b8ded1c 100644 --- a/service/app/handler_process_saved_event.go +++ b/service/app/handler_process_saved_event.go @@ -26,6 +26,8 @@ var ( ) ) +const sendEventToRelayTimeout = 5 * time.Second + type ProcessSavedEvent struct { id domain.EventId } @@ -165,6 +167,9 @@ func (h *ProcessSavedEventHandler) shouldReplaceContacts(ctx context.Context, ad } func (h *ProcessSavedEventHandler) maybeSendEventToRelay(ctx context.Context, event domain.Event) (err error) { + ctx, cancel := context.WithTimeout(ctx, sendEventToRelayTimeout) + defer cancel() + if !ShouldSendEventToRelay(event) { h.metrics.ReportEventSentToRelay(nosRelayAddress, SendEventToRelayDecisionIgnore, SendEventToRelayResultSuccess) return nil