jlcodes99/cockpit-tools · warning

[AutoBackup] 定期备份执行失败:

Error message

[AutoBackup] 定期备份执行失败:

What it means

The periodic auto-backup timer invokes runAutoBackupCycle inside a guarded (inFlight) block; any rejection is logged with this warning and swallowed so the timer keeps running. It means a scheduled backup did not complete and on-disk backups may be stale until the next cycle succeeds.

Source

Thrown at src/App.tsx:2252

    void syncWakeupStateOnStartup();
  }, []);

  useEffect(() => {
    const AUTO_BACKUP_STARTUP_DELAY_MS = 5 * 60 * 1000;
    const AUTO_BACKUP_POLL_INTERVAL_MS = 60 * 60 * 1000;
    let startupTimerId: number | undefined;
    let intervalId: number | undefined;
    let inFlight = false;

    const checkAutoBackup = async () => {
      if (inFlight) {
        return;
      }
      inFlight = true;
      try {
        await runAutoBackupCycle();
      } catch (error) {
        console.warn('[AutoBackup] 定期备份执行失败:', error);
      } finally {
        inFlight = false;
      }
    };

    startupTimerId = window.setTimeout(() => {
      void checkAutoBackup();
      intervalId = window.setInterval(() => {
        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);

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Read the logged error to distinguish IO (permission/path) from IPC errors
  2. Verify the configured backup path exists and is writable; recreate it or prompt the user to pick a new one
  3. Run one backup cycle manually to reproduce and capture the full error
  4. Check available disk space and that no other process locks the target files

Example fix

// before
await runAutoBackupCycle();
// after
await runAutoBackupCycle().catch((error) => {
  console.warn('[AutoBackup] 定期备份执行失败:', error);
  markBackupNeedsRetry();
});
Defensive patterns

Strategy: retry

Validate before calling

async function canWriteBackupDir(dir: string): Promise<boolean> {
  try {
    await writeTextFile(`${dir}/.write-test`, 'ok');
    await remove(`${dir}/.write-test`);
    return true;
  } catch {
    return false;
  }
}

Type guard

function isBackupConfig(v: unknown): v is { backupDir: string; intervalMs: number } {
  return isPlainObject(v) && typeof v.backupDir === 'string' && v.backupDir.length > 0 && typeof v.intervalMs === 'number';
}

Try / catch

inFlight = true;
try {
  await runAutoBackupCycle();
} catch (error) {
  console.warn('[AutoBackup] 定期备份执行失败:', error);
  scheduleBackupRetry();
} finally {
  inFlight = false;
}

Prevention

When it happens

Trigger: runAutoBackupCycle() throws: target backup directory missing or unwritable, disk full, backend backup command (Tauri IPC) fails, source data files locked, or backup config (interval/path) is invalid.

Common situations: User moved/deleted the backup directory; external drive disconnected; full disk; backend command signature changed after an app update.

Related errors


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