feat(electron): update logging for renderer process events; add detailed crash and unresponsive handling

This commit is contained in:
Ivan
2026-04-15 20:26:30 -05:00
parent 035fc3f741
commit dfd93fa9ad
+25
View File
@@ -401,6 +401,20 @@ function log(message) {
mainWindow.webContents.send("log", message);
}
function formatRenderProcessGoneDetails(details) {
if (!details) {
return "no details";
}
return JSON.stringify(
{
reason: details.reason || "unknown",
exitCode: details.exitCode,
},
null,
2,
);
}
function getDefaultStorageDir() {
// if we are running a windows portable exe, we want to use .reticulum-meshchat in the portable exe dir
// e.g if we launch "E:\Some\Path\MeshChat.exe" we want to use "E:\Some\Path\.reticulum-meshchat"
@@ -526,6 +540,12 @@ app.whenReady().then(async () => {
enableRemoteModule: false,
},
});
mainWindow.webContents.on("render-process-gone", (_event, details) => {
log(`Renderer process crashed: ${formatRenderProcessGoneDetails(details)}`);
});
mainWindow.webContents.on("unresponsive", () => {
log("Renderer process became unresponsive.");
});
// minimize to tray behavior
mainWindow.on("close", (event) => {
@@ -751,6 +771,11 @@ app.whenReady().then(async () => {
}
});
app.on("render-process-gone", (_event, webContents, details) => {
const wcId = webContents ? webContents.id : "unknown";
log(`render-process-gone for webContents ${wcId}: ${formatRenderProcessGoneDetails(details)}`);
});
function quit() {
if (!exeChildProcess) {
app.quit();