Skip to content

perf(storage): resolve connection secrets lazily and handle Keychain errors gracefully in local_db #916

Description

@ZhuchkaTriplesix

Summary

In LocalDb.getConnections (lib/core/storage/local_db.dart, lines 430–454):

final futures = rows.map((m) => _hydrateConnection(ConnectionRow.fromMap(m)));
return Future.wait(futures);

Where _hydrateConnection unconditionally awaits:

final secrets = await ConnectionSecretsStore.readForConnection(row.id!);
  1. Unbounded Parallel Keychain Requests: For N saved connections, Querya launches 2*N simultaneous OS secure storage reads (password and connection_string) on application startup. On Linux (D-Bus org.freedesktop.secrets) and macOS (Keychain), this causes lock contention, IPC bottlenecks, and timeouts (org.freedesktop.DBus.Error.NoReply).
  2. Missing Error Handling: _hydrateConnection lacks a try/catch block. If the platform secure store is locked or unavailable (e.g. minimal Linux setup without gnome-keyring or canceled prompt), getConnections() throws, failing to populate the entire connections tree in the sidebar.
  3. Unnecessary Eager Resolution: The sidebar tree only requires basic connection metadata (name, host, type, folder). Password and connection string secrets are not needed until the user explicitly initiates a database connection.

Repro

  1. Add 20+ database connections.
  2. Launch Querya on Linux or macOS.
  3. Observe high startup latency or D-Bus timeout errors when hydrating connections; if secure storage errors, no connections render in the UI.

Scope

  • Do not eagerly fetch passwords and connection strings for all connections in getConnections().
  • Add try/catch in _hydrateConnection and secret store readers to log errors gracefully and preserve basic row data rather than aborting connection tree rendering.
  • Resolve secrets on-demand when connect() is invoked for a specific connection.

Out of scope

  • Changing the underlying SQLite schema.

Activity

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

Metadata

Metadata

Labels

bugSomething isn't workingconnectionsDatabase connections, URI parsing, poolscoreCore library logic and servicesperformanceTheme parser epic label: performance

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions