jlcodes99/cockpit-tools · warning

[WorkbuddyAutoCheckin] 保存配置到 Rust 后端失败:

Error message

[WorkbuddyAutoCheckin] 保存配置到 Rust 后端失败:

What it means

saveWorkbuddyAutoCheckinConfig is the fire-and-forget wrapper around saveWorkbuddyAutoCheckinConfigAsync, which invokes 'save_workbuddy_auto_checkin_config' on the Rust backend. A rejected promise is caught and warned; the caller (e.g. ensureAccountSchedules) never sees the failure.

Source

Thrown at src/services/workbuddyAutoCheckinService.ts:127

    'migrate_workbuddy_auto_checkin_config',
    { legacyConfig },
  );
  cacheConfigLocally(config, true);
  return config;
}

export async function saveWorkbuddyAutoCheckinConfigAsync(config: WorkbuddyAutoCheckinConfig): Promise<void> {
  if (typeof window === 'undefined') {
    cacheConfigLocally(config);
    return;
  }
  await invoke('save_workbuddy_auto_checkin_config', { config });
  cacheConfigLocally(config, true);
}

export function saveWorkbuddyAutoCheckinConfig(config: WorkbuddyAutoCheckinConfig): void {
  void saveWorkbuddyAutoCheckinConfigAsync(config).catch((err) => {
    console.warn('[WorkbuddyAutoCheckin] 保存配置到 Rust 后端失败:', err);
  });
}

export function parseTimeToMinutes(timeStr: string): number {
  const parts = timeStr.split(':').map(Number);
  const h = parts[0] ?? 0;
  const m = parts[1] ?? 0;
  return h * 60 + m;
}

export function formatMinutesToTime(minutes: number): string {
  const h = Math.floor(minutes / 60) % 24;
  const m = minutes % 60;
  return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
}

export function getTodayDateString(): string {
  const now = new Date();

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Check the Rust command name and registered handlers match 'save_workbuddy_auto_checkin_config'
  2. Rebuild so the bundled Rust side supports the current config schema
  3. Add a caller-visible error path (return the promise or surface a UI toast) instead of swallowing it
  4. Retry the save after the backend reports ready

Example fix

// before
void saveWorkbuddyAutoCheckinConfigAsync(config).catch((err) => {
  console.warn('[WorkbuddyAutoCheckin] 保存配置到 Rust 后端失败:', err);
});
// after
export async function saveWorkbuddyAutoCheckinConfig(config: WorkbuddyAutoCheckinConfig): Promise<void> {
  try {
    await saveWorkbuddyAutoCheckinConfigAsync(config);
  } catch (err) {
    console.warn('[WorkbuddyAutoCheckin] 保存配置到 Rust 后端失败:', err);
    throw err;
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!('__TAURI_INTERNALS__' in window)) {
  console.warn('Tauri backend unavailable; skipping config save');
  return;
}

Try / catch

try {
  await invoke('save_workbuddy_auto_checkin_config', { config });
  cacheConfigLocally(config, true);
} catch (err) {
  console.warn('[WorkbuddyAutoCheckin] 保存配置到 Rust 后端失败:', err);
  // surface to caller/UI so the save is not silently lost
}

Prevention

When it happens

Trigger: invoke('save_workbuddy_auto_checkin_config') rejects: the Rust handler is missing/renamed, the config fails serialization in Rust, or IPC fails while the backend is unavailable.

Common situations: Frontend/backend version drift after renaming the command; corrupted backend config storage making the write fail; calling during shutdown before the Tauri runtime is ready.

Related errors


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