fix(NetworkMapScheduler): increase speed test request timeout to 5 minutes and improve error logging for aborted requests
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m44s

This commit is contained in:
2026-02-18 16:01:21 +07:00
parent e269b14f5e
commit 357503ee2f
+10 -6
View File
@@ -251,12 +251,16 @@ async function runJob(opts) {
} }
if (runSpeedTest) { if (runSpeedTest) {
// Таймаут запроса: замер может долго идти на медленных каналах (download + upload по durationSeconds каждый)
const SPEED_TEST_REQUEST_MS = 300000; // 5 мин
const withSpeed = connections.filter((c) => c.speedTestServerId && c.interfaceName); const withSpeed = connections.filter((c) => c.speedTestServerId && c.interfaceName);
const speedTasks = withSpeed.map((c) => async () => { const speedTasks = withSpeed.map((c) => async () => {
const key = speedKey(c.fromKey, c.toKey); const key = speedKey(c.fromKey, c.toKey);
const server = servers.find((s) => (s.id || s.dns || s.ip) === c.speedTestServerId); const server = servers.find((s) => (s.id || s.dns || s.ip) === c.speedTestServerId);
const serverLabel = server ? (server.dns || server.ip || server.id) : c.speedTestServerId; const serverLabel = server ? (server.dns || server.ip || server.id) : c.speedTestServerId;
const speedLabel = `${serverLabel} / ${c.interfaceName}`; const speedLabel = `${serverLabel} / ${c.interfaceName}`;
const ac = new AbortController();
const timeoutId = setTimeout(() => ac.abort(), SPEED_TEST_REQUEST_MS);
try { try {
const res = await fetch(`${baseUrl}/api/mikrotik/speed-test`, { const res = await fetch(`${baseUrl}/api/mikrotik/speed-test`, {
method: 'POST', method: 'POST',
@@ -266,12 +270,9 @@ async function runJob(opts) {
interfaceName: c.interfaceName, interfaceName: c.interfaceName,
forceRefresh: true, forceRefresh: true,
}), }),
signal: (() => { signal: ac.signal,
const ac = new AbortController();
setTimeout(() => ac.abort(), 120000);
return ac.signal;
})(),
}); });
clearTimeout(timeoutId);
const data = await res.json().catch(() => ({})); const data = await res.json().catch(() => ({}));
if (data?.ok && (data.tcpDownloadBps != null || data.tcpUploadBps != null)) { if (data?.ok && (data.tcpDownloadBps != null || data.tcpUploadBps != null)) {
speedMap[key] = { speedMap[key] = {
@@ -290,8 +291,11 @@ async function runJob(opts) {
log(`Скорость ${speedLabel}: ${speedErr}`); log(`Скорость ${speedLabel}: ${speedErr}`);
return null; return null;
} catch (e) { } catch (e) {
clearTimeout(timeoutId);
speedMap[key] = null; speedMap[key] = null;
log(`Скорость ${speedLabel}: ошибка ${e?.message || e}`); const msg = e?.message || e;
const isAbort = String(msg).toLowerCase().includes('abort');
log(`Скорость ${speedLabel}: ошибка ${isAbort ? 'таймаут или отмена запроса' : msg}`);
return null; return null;
} }
}); });