To ensure that the renderer process doesn't die before the necessary functions run, we can use Inter-Process Communication (IPC) more effectively. Here's one approach:
- In the main process:
const { app, BrowserWindow, ipcMain } = require('electron');
let mainWindow;