From 0db8085b833c038d5c5766b870b7f1ad98ccbd66 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 14 Mar 2024 17:39:28 +0100 Subject: Add timeout to webhook fetch request. --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 { -- cgit v1.2.3