fix(uptime): объяснить неизвестный результат теста скорости

This commit is contained in:
Denozordec committed 2026-10-10 01:41:15 +07:00
1 parent dbe1e7c917
commit 5944e5e751
13 files changed
+190 -24

No files matched your search

@@ -0,0 +1,6 @@
/** A lost transport receipt cannot establish whether RouterOS completed the test. */
export function speedRunErrorMessage(raw: string): string {
return /timed out|socket hang up|ECONNRESET/i.test(raw)
? "Результат теста скорости неизвестен: ответ устройства не получен. Проверьте его состояние перед повторным запуском."
: raw
}
+2 -7
View File
@@ -10,6 +10,7 @@ import { parsePing } from "./uptime-collector.js"
import { assertBandwidthTestCompleted } from "./bandwidth-test-status.js"
import { assertSpeedProbeContext, persistSpeedRun, SpeedRunPersistenceUnknown, type SpeedProbeContext } from "./speed-run-persistence.js"
import { readBandwidthTestRates } from "./bandwidth-test-rates.js"
import { speedRunErrorMessage } from "./speed-run-error-message.js"
type SpeedWriteTransaction = Parameters<Parameters<typeof db.transaction>[0]>[0]
function speedProbeContextWhere(target: SpeedProbeContext) {
@@ -73,12 +74,6 @@ export interface SpeedTestRunResult {
}
}
function humanizeSpeedError(raw: string): string {
return /timed out|socket hang up|ECONNRESET/i.test(raw)
? "BTTest timeout/socket hang up: проверь доступность destination, /tool bandwidth-server, firewall и корректность интерфейсов"
: raw
}
/** Полный цикл bandwidth-test + after-ping + запись в БД. Вызывать внутри withBtestNodeLocks при необходимости — здесь lock уже снаружи. */
export async function executeBandwidthSpeedTestInner(params: SpeedTestRunParams): Promise<SpeedTestRunResult> {
const probeId = String(params.probeId ?? "").trim()
@@ -232,7 +227,7 @@ export async function recordSpeedTestFailure(params: {
message: string
}) {
const probeId = String(params.probeId ?? "").trim()
const message = humanizeSpeedError(params.message)
const message = speedRunErrorMessage(params.message)
await persistSpeedRun<SpeedWriteTransaction, SpeedProbeContext>(probeId ? {
id: probeId, srcServerId: params.srcServerId, dstServerId: params.dstServerId,
srcInterface: String(params.srcInterface ?? "").trim(), dstInterface: String(params.dstInterface ?? "").trim(),