Skip to content

[audit] hot-exit: mainWindowRestoreStarted flag never reset on success #318

@claude

Description

@claude

Problem

In src/utils/hotExit/useHotExitRestore.ts:30,52,77, the module-level mainWindowRestoreStarted flag is set to true on success (line 52) but only reset to false on failure (line 77).

Once a successful restore completes, the flag stays true for the lifetime of the module. If the user triggers a second hot exit restart within the same process (e.g., two auto-update restarts without the process dying), restoreMainWindowState() will silently bail out at lines 48-50.

Impact

Second hot exit restore in the same process would fail to restore the main window. While unlikely (requires two restarts without process death), the guard is asymmetric and could cause hard-to-debug failures.

Suggested fix

Reset the flag after successful restore completes:

// After line 74, inside the `if (allDone)` block:
if (allDone) {
  await emit(HOT_EXIT_EVENTS.RESTORE_COMPLETE, {});
  mainWindowRestoreStarted = false; // Allow future restores
}

Or reset it after the try block completes successfully (before the catch).

File

src/utils/hotExit/useHotExitRestore.ts:30,48-52,77

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditCodebase audit findingbugSomething isn't workinghot-exitHot exit / session restore

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions