Skip to content

fix(storage): add disaster recovery fallback UI when LocalDb fails to open on startup #1375

Description

@ZhuchkaTriplesix

Problem

In lib/main.dart (lines 32–40):

await LocalDb.initFfi();
await SyntaxHighlightService.ensureInitialized();
await ThemeController.instance.load();
await UiScaleController.instance.load();
await QueryaMotionController.instance.load();
...
runApp(const QueryaApp());
  1. ThemeController, UiScaleController, and QueryaMotionController all call LocalDb.instance in their load() methods during startup before runApp is executed.
  2. If querya.db fails to open (e.g. SQLite database locked by a stale process, file corruption, filesystem permission error, or WAL checkpoint failure):
    • LocalDb._doOpen() throws an unhandled exception.
    • The exception is caught by runZonedGuarded in main.dart, which only prints debugPrint('Unhandled async error: $error\n$stack').
    • runApp(const QueryaApp()) is never called.
    • The user is presented with a blank, frozen window, with no indication of why the app failed to launch and no way to recover.

Scope

  • Wrap early LocalDb initialization and controller loads in a try-catch block in main.dart.
  • If LocalDb fails to open, launch a minimal recovery UI (QueryaStartupRecoveryApp) that presents the error message and offers recovery actions:
    • Retry opening the database.
    • Unlock database / remove stale WAL locks.
    • Start in Safe Mode with a temporary or clean profile.
    • Export/backup existing querya.db file for diagnosis.
  • Add tests verifying startup error handling when LocalDb throws.

Activity

  1. added
    bugSomething isn't working
    frontendTheme parser epic label: frontend
    stabilityTheme parser epic label: stability
    storageTheme parser epic label: storage
    coreCore library logic and services
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1382 (merged into dev).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringbugSomething isn't workingcoreCore library logic and servicesfrontendTheme parser epic label: frontendstabilityTheme parser epic label: stabilitystorageTheme parser epic label: storage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions