summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-03-14 17:39:28 +0100
committerTor Andersson <tor@ccxvii.net>2024-03-14 17:39:28 +0100
commit0db8085b833c038d5c5766b870b7f1ad98ccbd66 (patch)
tree50f7be180cf26977b6bc9b9bf92175ec8b3edc92
parent68d86fe46b8182a043cfc31bac5ca42f2b52e622 (diff)
downloadserver-0db8085b833c038d5c5766b870b7f1ad98ccbd66.tar.gz
Add timeout to webhook fetch request.
-rw-r--r--server.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/server.js b/server.js
index 56a3413..b2f70f4 100644
--- a/server.js
+++ b/server.js
@@ -2300,7 +2300,12 @@ async function send_webhook(user_id, webhook, message, retry=2) {
const text = webhook.prefix + " " + message
const data = webhook.format ? JSON.stringify({ [webhook.format]: text }) : text
const headers = webhook.format ? webhook_json_options : webhook_text_options
- const res = await fetch(webhook.url, { method: "POST", headers: headers, body: data })
+ const res = await fetch(webhook.url, {
+ method: "POST",
+ signal: AbortSignal.timeout(6000),
+ headers: headers,
+ body: data
+ })
if (res.ok)
on_webhook_success(user_id)
else {