fix(db): resolve SQLite channel and initialization issues
- Add sqlite-status to valid IPC channels - Fix SQLite ready signal handling - Improve database status tracking - Add proper error handling for status updates - Keep database connection open during initialization Technical Details: - Added sqlite-status to VALID_CHANNELS.invoke list - Implemented sqlite-status handler with proper verification - Added database open state verification - Improved error handling and logging - Fixed premature database closing Testing Notes: - Verify SQLite ready signal is received correctly - Confirm database stays open after initialization - Check status updates are processed properly - Verify error handling for invalid states Security: - Validates all IPC channels - Verifies database state before operations - Maintains proper connection lifecycle - Implements proper error boundaries Author: Matthew Raymer
This commit is contained in:
@@ -868,5 +868,35 @@ export function setupSQLiteHandlers(): void {
|
||||
}
|
||||
});
|
||||
|
||||
// Handler for SQLite status updates
|
||||
registerHandler('sqlite-status', async (_event, status: { status: string; database: string; timestamp: number }) => {
|
||||
logger.debug('SQLite status update:', status);
|
||||
try {
|
||||
startDatabaseOperation();
|
||||
if (!pluginState.instance) {
|
||||
throw new SQLiteError('Plugin not initialized', 'sqlite-status');
|
||||
}
|
||||
|
||||
// Verify database is still open
|
||||
const isOpen = await pluginState.instance.isDBOpen({ database: status.database });
|
||||
if (!isOpen) {
|
||||
throw new SQLiteError('Database not open', 'sqlite-status');
|
||||
}
|
||||
|
||||
logger.info('SQLite status update processed:', {
|
||||
status: status.status,
|
||||
database: status.database,
|
||||
timestamp: new Date(status.timestamp).toISOString()
|
||||
});
|
||||
|
||||
return { success: true, isOpen };
|
||||
} catch (error) {
|
||||
logger.error('SQLite status update failed:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
endDatabaseOperation();
|
||||
}
|
||||
});
|
||||
|
||||
logger.info('SQLite IPC handlers setup complete');
|
||||
}
|
||||
Reference in New Issue
Block a user