Zackriya-Solutions/meetily · critical

Failed to initialize database

Error message

Failed to initialize database

What it means

Startup initialization is wrapped in block_on(...).expect: any failure inside initialize_database_on_startup — first-launch detection (app_data_dir), creating the sqlite pool, running migrations, or legacy db copy — panics during Tauri setup and aborts launch. Typical underlying causes: corrupted meeting_minutes.sqlite, database locked by another instance, read-only app-data dir, disk full, sqlx migration mismatch.

Source

Thrown at frontend/src-tauri/src/lib.rs:500

                    }
                }
            });

            // Trigger system audio permission request on startup (similar to microphone permission)
            // #[cfg(target_os = "macos")]
            // {
            //     tauri::async_runtime::spawn(async {
            //         if let Err(e) = audio::permissions::trigger_system_audio_permission() {
            //             log::warn!("Failed to trigger system audio permission: {}", e);
            //         }
            //     });
            // }

            // Initialize database (handles first launch detection and conditional setup)
            tauri::async_runtime::block_on(async {
                database::setup::initialize_database_on_startup(&_app.handle()).await
            })
            .expect("Failed to initialize database");

            // Initialize bundled templates directory for dynamic template discovery
            log::info!("Initializing bundled templates directory...");
            if let Ok(resource_path) = _app.handle().path().resource_dir() {
                let templates_dir = resource_path.join("templates");
                log::info!("Setting bundled templates directory to: {:?}", templates_dir);
                summary::templates::set_bundled_templates_dir(templates_dir);
            } else {
                log::warn!("Failed to resolve resource directory for templates");
            }

            Ok(())
        })
        .on_window_event(|window, event| {
            if let tauri::WindowEvent::CloseRequested { api, .. } = event {
                if window.label() == "main" {
                    api.prevent_close();
                    if let Err(e) = window.hide() {

View on GitHub (pinned to 0281737d87)

Solutions

  1. Replace expect with error propagation: log the underlying error and show a user-facing dialog with a retry/quit choice
  2. If the db is corrupt: close the app, move meeting_minutes.sqlite aside, relaunch to let it recreate (accepts data loss of old meetings)
  3. Enforce single-instance (Tauri single-instance plugin) to avoid locked-db races
  4. Keep WAL checkpointing on exit (already present) and test startup with a full disk / read-only dir

Example fix

// before
tauri::async_runtime::block_on(async {
    database::setup::initialize_database_on_startup(&_app.handle()).await
}).expect("Failed to initialize database");

// after
if let Err(e) = tauri::async_runtime::block_on(async {
    database::setup::initialize_database_on_startup(&_app.handle()).await
}) {
    log::error!("database init failed: {e:#}");
    std::process::exit(1); // or show a native error dialog
}
Defensive patterns

Strategy: fallback

Validate before calling

// preflight before startup init
let dir = app.path().app_data_dir()?;
if dir.read_file_test_failed() { /* rename aside */ }

Try / catch

if let Err(e) = tauri::async_runtime::block_on(async {
    database::setup::initialize_database_on_startup(&app.handle()).await
}) {
    log::error!("database init failed: {e:#}");
    // show dialog, offer reset: move meeting_minutes.sqlite aside and retry
}

Prevention

When it happens

Trigger: Starting the app with a corrupt or half-written sqlite file (previous crash mid-write), launching a second instance racing on the same database file, permissions changed on the app data directory, or running an older build against a newer schema.

Common situations: Force-quit during a meeting save, cloud-synced home folders locking the sqlite file, antivirus holding the db, users downgrading app versions.

Related errors


AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16). Data as JSON: /api/errors/c4641b315636acc3. Report an issue: GitHub.