Skip to content

Commit 92471b9

Browse files
committed
fix: prevent GUI crash on second launch in desktop app
1 parent e082222 commit 92471b9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ui/main/rootWindow.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,20 @@ export const setupRootWindow = (): void => {
516516
export const showRootWindow = async (): Promise<void> => {
517517
const browserWindow = await getRootWindow();
518518

519+
// Handle renderer process crashes
520+
browserWindow.webContents.on('render-process-gone', async (event, details) => {
521+
console.error('Renderer process crashed:', details.reason);
522+
try {
523+
const session = browserWindow.webContents.session;
524+
await session.clearCache();
525+
await session.clearStorageData();
526+
console.log('Cache cleared. Reloading window...');
527+
browserWindow.reload();
528+
} catch (error) {
529+
console.error('Failed to recover from crash:', error);
530+
}
531+
});
532+
519533
browserWindow.loadFile(path.join(app.getAppPath(), 'app/index.html'));
520534

521535
if (process.env.NODE_ENV === 'development') {

0 commit comments

Comments
 (0)