Skip to content

Commit d521e2a

Browse files
FIX (slack): Add request timeout for 30 seconds
1 parent 82eca75 commit d521e2a

File tree

1 file changed

+6
-1
lines changed
  • backend/internal/features/notifiers/models/slack

1 file changed

+6
-1
lines changed

backend/internal/features/notifiers/models/slack/model.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,18 @@ func (s *SlackNotifier) Send(
7070
maxAttempts = 5
7171
defaultBackoff = 2 * time.Second // when Retry-After header missing
7272
backoffMultiplier = 1.5 // use exponential growth
73+
requestTimeout = 30 * time.Second
7374
)
7475

7576
var (
7677
backoff = defaultBackoff
7778
attempts = 0
7879
)
7980

81+
client := &http.Client{
82+
Timeout: requestTimeout,
83+
}
84+
8085
for {
8186
attempts++
8287

@@ -92,7 +97,7 @@ func (s *SlackNotifier) Send(
9297
req.Header.Set("Content-Type", "application/json; charset=utf-8")
9398
req.Header.Set("Authorization", "Bearer "+botToken)
9499

95-
resp, err := http.DefaultClient.Do(req)
100+
resp, err := client.Do(req)
96101
if err != nil {
97102
return fmt.Errorf("send slack message: %w", err)
98103
}

0 commit comments

Comments
 (0)