diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-03-14 17:39:28 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-03-14 17:39:28 +0100 |
commit | 0db8085b833c038d5c5766b870b7f1ad98ccbd66 (patch) | |
tree | 50f7be180cf26977b6bc9b9bf92175ec8b3edc92 | |
parent | 68d86fe46b8182a043cfc31bac5ca42f2b52e622 (diff) | |
download | server-0db8085b833c038d5c5766b870b7f1ad98ccbd66.tar.gz |
Add timeout to webhook fetch request.
-rw-r--r-- | server.js | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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 { |