jlcodes99/cockpit-tools · warning

[WorkbuddyAutoCheckin] 迁移旧版自动签到配置失败:

Error message

[WorkbuddyAutoCheckin] 迁移旧版自动签到配置失败:

What it means

On startup, MainApp migrates legacy Workbuddy auto-checkin settings stored in WebView localStorage to the Rust background scheduler via migrateWorkbuddyAutoCheckinConfigAsync. A rejection is caught on the promise and logged with this warning. If migration fails, old checkin settings remain only in localStorage and the native scheduler will not run the legacy configuration.

Source

Thrown at src/App.tsx:2279

        void checkAutoBackup();
      }, AUTO_BACKUP_POLL_INTERVAL_MS);
    }, AUTO_BACKUP_STARTUP_DELAY_MS);

    return () => {
      if (startupTimerId !== undefined) {
        window.clearTimeout(startupTimerId);
      }
      if (intervalId !== undefined) {
        window.clearInterval(intervalId);
      }
    };
  }, []);

  // 将旧版本保存在 WebView localStorage 中的设置迁移到 Rust 后台调度器。
  useEffect(() => {
    clearLegacyWorkbuddyAutoCheckinLogs();
    void migrateWorkbuddyAutoCheckinConfigAsync(getWorkbuddyAutoCheckinConfig()).catch((err) => {
      console.warn('[WorkbuddyAutoCheckin] 迁移旧版自动签到配置失败:', err);
    });
  }, []);

  // Check for updates on startup
  useEffect(() => {
    if (!updateRuntimeInfoLoaded) {
      return;
    }

    const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000;
    let updateCheckInFlight = false;
    let intervalId: number | undefined;

    const checkUpdates = async (trigger: 'startup' | 'hourly') => {
      if (updateCheckInFlight) {
        writeUpdateLog('info', `${trigger === 'startup' ? '启动' : '每小时轮询'}更新检查跳过:上一次尚未结束`);
        return;
      }

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Read the logged err to see if it is an IPC 'command not found' vs a parse error
  2. Validate/JSON-parse the legacy config from localStorage before calling migrate; drop safely unparseable data
  3. Confirm the backend migration command name/signature matches the frontend invoke call after any rename
  4. Make migration idempotent and retry on next startup, then clear legacy keys only on success

Example fix

// before
void migrateWorkbuddyAutoCheckinConfigAsync(getWorkbuddyAutoCheckinConfig()).catch((err) => {
  console.warn('[WorkbuddyAutoCheckin] 迁移旧版自动签到配置失败:', err);
});
// after
const legacy = safeParseLegacyConfig(getWorkbuddyAutoCheckinConfig());
if (legacy) {
  await migrateWorkbuddyAutoCheckinConfigAsync(legacy); // retry next startup on failure
} else {
  clearLegacyWorkbuddyAutoCheckinLogs();
}
Defensive patterns

Strategy: validation

Validate before calling

function safeParseLegacyConfig(raw: string | null): LegacyCheckinConfig | null {
  if (!raw) return null;
  try {
    const parsed = JSON.parse(raw);
    return parsed && typeof parsed === 'object' ? parsed : null;
  } catch {
    return null;
  }
}

Type guard

function isLegacyCheckinConfig(v: unknown): v is LegacyCheckinConfig {
  return isPlainObject(v) && typeof (v as { enabled?: unknown }).enabled === 'boolean';
}

Try / catch

getWorkbuddyAutoCheckinConfig()
  .then((cfg) => migrateWorkbuddyAutoCheckinConfigAsync(cfg))
  .catch((err) => {
    console.warn('[WorkbuddyAutoCheckin] 迁移旧版自动签到配置失败:', err);
    // leave legacy keys intact; retry next startup
  });

Prevention

When it happens

Trigger: migrateWorkbuddyAutoCheckinConfigAsync(...) rejects: the backend migrate command fails (IPC error, scheduler not ready), the legacy localStorage config is corrupt/unparseable, or clearLegacyWorkbuddyAutoCheckinLogs-related storage access throws first.

Common situations: Upgrading from an old app version whose localStorage schema differs; corrupted JSON in localStorage; backend command renamed after refactors so the frontend calls a missing command.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/8c6aeb82f6cb55cc. Report an issue: GitHub.