fix(conn): 拔线后不再永远「已连接」

1) pollStatus 把 5s 超时 AbortError / HTTP 非 2xx 计入失败,走离线+清指标
2) DeviceLink 快照不得把本页已判离线改回在线(Owner 连败 3 次前会盖绿灯)
This commit is contained in:
cbb
2026-09-16 20:38:37 +08:00
parent 5459bdeff7
commit 91a534514d
4 changed files with 15 additions and 6 deletions
+9 -2
View File
@@ -237,12 +237,19 @@ export async function pollStatus() {
if (window.isEsp32Rebooting) {
window.applyRebootingRuntimeState();
}
} else {
/* HTTP 非 2xx:设备在但不健康,也必须走失败路径,否则 UI 永远停在「已连接」 */
var httpErr = new Error('HTTP ' + resp.status);
httpErr.status = resp.status;
throw httpErr;
}
clearTimeout(pollTimer);
} catch (e) {
clearTimeout(pollTimer);
// 自身 AbortController 触发的取消不算失败,静默返回
if (e && e.name === "AbortError") return;
/* 5s 超时 abort:拔线后 TCP 常挂死到超时,不是「主动取消」。
* 旧逻辑把所有 AbortError 静默 return → 拔掉后永远「已连接」。
* 仅上传暂停导致的 abort 不算失败(pausePollingForUpload 已 abort 在途请求)。 */
if (e && e.name === "AbortError" && window.pollingPausedForUpload) return;
// 先判定 OTA 是否进行中:OTA 期间所有失败都不计入 consecutivePollFailures,
// 也不触发诊断。避免"上传完成→finalize→重启"窗口期失败计数累积,
// 切回 IDLE 瞬间立即触发 5-fail 诊断,干扰进度显示。