Skip to content

An AI-powered search engine with a generative UI

fix: add timeout to Slack webhook request to prevent hanging

Yoshiki Miura1ee59238c563
diff --git a/lib/actions/site-feedback.ts b/lib/actions/site-feedback.ts
index 10beae72..bd945c48 100644
--- a/lib/actions/site-feedback.ts
+++ b/lib/actions/site-feedback.ts
@@ -94,13 +94,22 @@ export async function submitFeedback(data: {
]
}
- await fetch(slackWebhookUrl, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(slackMessage)
- })
+ // Add timeout to prevent hanging if Slack is unresponsive
+ const controller = new AbortController()
+ const timeout = setTimeout(() => controller.abort(), 10000) // 10 seconds
+
+ try {
+ await fetch(slackWebhookUrl, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(slackMessage),
+ signal: controller.signal
+ })
+ } finally {
+ clearTimeout(timeout)
+ }
} catch (slackError) {
// Log Slack error but don't fail the request
console.error('Failed to send Slack notification:', slackError)