- Fix window.location.href usage in DeepLinkRedirectView for Capacitor
context: check if already in native app and use router navigation
instead of window.location.href (which doesn't work in Capacitor)
- Consolidate teardown() and _cleanupOnFailure() by extracting shared
cleanup logic to _performCleanup() method
- Make teardown() private since it's unused (kept for potential future use)
- Ensure both cleanup paths reset initializationPromise for consistency
This fixes navigation issues when DeepLinkRedirectView is accessed from
within the Capacitor app and removes code duplication in cleanup logic.
- Removed excessive debug/success logs from CapacitorPlatformService
- Removed verbose singleton tracking logs from PlatformServiceFactory
- Removed unnecessary platform !== 'web' check in applyPragmas (service only loads for Capacitor)
- Compressed try-catch blocks in applyPragmas for cleaner code
- Extracted executor adapters to createExecutor() methods in both CapacitorPlatformService and AbsurdSqlDatabaseService for consistency and testability
This reduces console noise while maintaining essential error logging.
- Replace window.location.href with router.push() for /seed-backup navigation
- Prevents full page reload that was causing app remount and singleton loss
- Maintains singleton persistence and database connection across navigation
This fixes the issue where navigating to seed-backup page via the reminder
modal was triggering a full page reload, causing the PlatformService singleton
to be lost and database to be re-initialized unnecessarily.
- Refactor PlatformServiceFactory to use globalThis-based singleton storage
- Store singleton in globalThis/window/self for persistence across module reloads
- Add comprehensive debug logging for singleton lifecycle tracking
- Implement Proxy-based lazy initialization to avoid circular dependencies
- Add HMR support to preserve singleton across hot module replacement
- Enhance CapacitorPlatformService database connection recovery
- Improve getOrCreateConnection() with robust error handling
- Add recovery path for 'already exists' desync scenarios
- Wrap retrieveConnection and db.open() calls in try-catch blocks
- Handle cases where retrieveConnection throws instead of returning null
- Add 50ms delay after closeConnection to allow native cleanup
- Add shared SQLite connection manager (sqlite.ts)
- Centralize SQLiteConnection instance creation
- Prevent connection desync issues across the application
This addresses the issue where PlatformService singleton was being
recreated on navigation, causing repeated database initialization
attempts and connection desync errors.
- Added comprehensive INVARIANTS documentation to _applyPragmasOnExistingConnection()
- Added ORDERING GUARD documentation to _initialize() and _ensureConnection()
- Enhanced iOS compatibility logging for WAL mode failures
- Added invariant reference comments throughout PRAGMA code paths
- Improved error handling with non-fatal WAL failure handling
- All invariants documented to prevent regression:
1. foreign_keys via run()
2. journal_mode via query() with iOS compatibility
3. busy_timeout via query() with fallback
4. synchronous skipped in fallback path
5. this.db must be set before returning
This locks in the v3.3.3 fix and ensures stability on Android and iOS.
- Fix fallback PRAGMA method to open newly created connections immediately
- Prevents 'database not opened' errors when applying PRAGMAs
- Newly created connections are now opened before PRAGMA application
- Adds explicit logging for connection opening in fallback path
- Ensures journal_mode is correctly set to WAL instead of unknown
This fixes the issue where PRAGMAs were being applied on connections
that weren't yet opened, causing initialization failures. The fix ensures
that after creating a connection in the fallback path, it is immediately
opened before attempting to apply PRAGMAs.
Tested: Connection opens successfully, PRAGMAs apply correctly,
journal_mode set to WAL, initialization completes in ~38ms.