From 22ad0eec1d000d24c317e2c279765b6c66cc4f22 Mon Sep 17 00:00:00 2001 From: ale Date: Tue, 24 Sep 2024 01:18:05 +0200 Subject: [PATCH] constant timeouts --- lib/constant.js | 4 +++- lib/fediblock.js | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/constant.js b/lib/constant.js index 8e724e8..1d4c595 100644 --- a/lib/constant.js +++ b/lib/constant.js @@ -10,5 +10,7 @@ module.exports = { workers: 3, // async concurrent workers to scan schedule: '5,11,17,23', // UTC hours to publish bot followers federated stats filterdomains: ['activitypub-troll.cf'], // domains filtered to scan - initialscan: 'mastodon.social' // initial federated domain to scan + initialscan: 'mastodon.social', // initial federated domain to scan + timeout: 3000, // Timeout of each scan request + abort_timeout: 4000 // Timeout of abort scan request } diff --git a/lib/fediblock.js b/lib/fediblock.js index a9a4661..71bd9fe 100644 --- a/lib/fediblock.js +++ b/lib/fediblock.js @@ -3,7 +3,6 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0 module.exports = async (client, apex, app) => { const util = require('./util')(apex), constant = require('./constant'), - https = require('https'), schedule = require('node-schedule'), workers = constant.workers, getAccount = api => { @@ -22,15 +21,12 @@ module.exports = async (client, apex, app) => { const ac = new AbortController() setTimeout(() => { ac.abort() - }, 5000) + }, constant.abort_timeout) const response = await fetch(uri, { headers: { 'User-Agent': constant.agent }, - agent: new https.Agent({ - keepAlive: false - }), signal: ac.signal, keepalive: false, - timeout: 3000 + timeout: constant.timeout }), json = await response.json() // setImmediate(() => { ac.abort() })