mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-06-21 07:23:56 +08:00
fix(dashboard): skip stale self-heal writes when load superseded
_loadDashboardDataInner could call writeOpenclawConfig after a newer loadDashboardData() bumped _dashboardLoadSeq, because the seq guard ran only after the self-heal block. Abort superseded loads before rendering and before patching so queued refreshes do not clobber config. Co-authored-by: 晴天 <1186258278@users.noreply.github.com>
This commit is contained in:
@@ -219,7 +219,7 @@ function normalizeDefaultModelConfig(config) {
|
||||
}
|
||||
|
||||
async function loadDashboardData(page, fullRefresh = false) {
|
||||
// 并发保护:如果上一次加载仍在进行,跳过本次(fullRefresh 除外)
|
||||
// 串行化:多次触发会排队执行;_dashboardLoadSeq 在排队时仍会递增,内层需在写配置前检查避免过期写入
|
||||
const loadSeq = ++_dashboardLoadSeq
|
||||
_dashboardLoadChain = _dashboardLoadChain.catch(() => {}).then(() => _loadDashboardDataInner(page, fullRefresh, loadSeq))
|
||||
return _dashboardLoadChain
|
||||
@@ -246,6 +246,7 @@ async function _loadDashboardDataInner(page, fullRefresh, loadSeq) {
|
||||
|
||||
// 第一波:服务状态 + 配置 + 版本 → 立即渲染统计卡片
|
||||
const [servicesRes, configRes, panelConfigRes] = await coreP
|
||||
if (loadSeq !== _dashboardLoadSeq || !page.isConnected) return
|
||||
const services = servicesRes.status === 'fulfilled' ? servicesRes.value : []
|
||||
let version = _dashboardVersionCache || {}
|
||||
let config = configRes.status === 'fulfilled' ? configRes.value : null
|
||||
@@ -273,6 +274,7 @@ async function _loadDashboardDataInner(page, fullRefresh, loadSeq) {
|
||||
if (needsPatch) {
|
||||
try {
|
||||
const freshConfig = await api.readOpenclawConfig()
|
||||
if (loadSeq !== _dashboardLoadSeq || !page.isConnected) return
|
||||
let patched = false
|
||||
if (!freshConfig.gateway) freshConfig.gateway = {}
|
||||
if (!freshConfig.gateway.mode) { freshConfig.gateway.mode = 'local'; patched = true }
|
||||
|
||||
Reference in New Issue
Block a user