From 8ae9573b07b5655c69a3df20ca93c758a374042e Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 1 Feb 2025 14:42:21 +0800 Subject: [PATCH] add timeout to notification context --- internal/notif/providers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/notif/providers.go b/internal/notif/providers.go index f2121df..0de2a2c 100644 --- a/internal/notif/providers.go +++ b/internal/notif/providers.go @@ -4,6 +4,7 @@ import ( "context" "io" "net/http" + "time" E "github.com/yusing/go-proxy/internal/error" gphttp "github.com/yusing/go-proxy/internal/net/http" @@ -40,6 +41,10 @@ func notifyProvider(ctx context.Context, provider Provider, msg *LogMessage) err if err != nil { return E.PrependSubject(provider.GetName(), err) } + + ctx, cancel := context.WithTimeout(ctx, 2*time.Second) + defer cancel() + req, err := http.NewRequestWithContext( ctx, http.MethodPost,