mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
Ensure dialog:selectFolder IPC handler always sends reply
Add try-catch wrapper and isDestroyed() check to prevent "reply was never sent" errors when the window closes during dialog operations. Fixes MAESTRO-58
This commit is contained in:
@@ -61,9 +61,13 @@ export function registerSystemHandlers(deps: SystemHandlerDependencies): void {
|
||||
// ============ Dialog Handlers ============
|
||||
|
||||
// Folder selection dialog
|
||||
// Wrapped in try-catch to ensure a reply is always sent, even if the window
|
||||
// is closed while the dialog is open or other unexpected errors occur.
|
||||
// Fixes MAESTRO-58: "reply was never sent"
|
||||
ipcMain.handle('dialog:selectFolder', async () => {
|
||||
try {
|
||||
const mainWindow = getMainWindow();
|
||||
if (!mainWindow) return null;
|
||||
if (!mainWindow || mainWindow.isDestroyed()) return null;
|
||||
|
||||
const result = await dialog.showOpenDialog(mainWindow, {
|
||||
properties: ['openDirectory', 'createDirectory'],
|
||||
@@ -75,6 +79,11 @@ export function registerSystemHandlers(deps: SystemHandlerDependencies): void {
|
||||
}
|
||||
|
||||
return result.filePaths[0];
|
||||
} catch (error) {
|
||||
// Log the error but return null to ensure IPC reply is sent
|
||||
logger.error('dialog:selectFolder failed', 'Dialog', { error });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// File save dialog
|
||||
|
||||
Reference in New Issue
Block a user