From e2f02d0fea9c477220e136034e4e509508cd10bb Mon Sep 17 00:00:00 2001 From: Dave Page Date: Wed, 2 Dec 2026 15:51:57 +0000 Subject: [PATCH] Log uncaught UI errors and crashed renderer or GPU processes in the desktop runtime. #10760 A blank pgAdmin window can come from an uncaught error whilst React renders (React 19 then unmounts the whole tree), or from a crashed renderer or GPU process, but neither leaves anything in the runtime log. React 19 reports uncaught render errors through reportError() rather than console.error, so the existing console capture misses them. Log window 'error' and 'unhandledrejection' events from the main window, and record Electron's render-process-gone and child-process-gone events, so that the next occurrence can be diagnosed from File -> View Logs. Refs #10760 --- runtime/src/js/pgadmin.js | 10 ++++++++++ web/pgadmin/browser/templates/browser/index.html | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/runtime/src/js/pgadmin.js b/runtime/src/js/pgadmin.js index 929b9a98ef1..a8817709c6d 100644 --- a/runtime/src/js/pgadmin.js +++ b/runtime/src/js/pgadmin.js @@ -97,6 +97,16 @@ if (!gotTheLock) { }); } +// A crashed renderer or GPU process leaves a window blank with nothing in +// the log to say why, so record it. +app.on('render-process-gone', (_e, contents, details) => { + const url = contents.isDestroyed() ? '' : ` for ${contents.getURL()}`; + misc.writeServerLog(`Renderer process gone${url}: reason=${details.reason}, exitCode=${details.exitCode}`); +}); +app.on('child-process-gone', (_e, details) => { + misc.writeServerLog(`Child process gone: type=${details.type}, reason=${details.reason}, exitCode=${details.exitCode}`); +}); + // Override the paths above, if a developer needs to if (fs.existsSync('dev_config.json')) { try { diff --git a/web/pgadmin/browser/templates/browser/index.html b/web/pgadmin/browser/templates/browser/index.html index f72b7275430..c0777bbc578 100644 --- a/web/pgadmin/browser/templates/browser/index.html +++ b/web/pgadmin/browser/templates/browser/index.html @@ -30,6 +30,22 @@ }); } } + + // Uncaught errors do not pass through console.error, so they would + // otherwise never reach the log. This matters most for errors thrown + // whilst React renders: React 19 reports those with reportError() and + // then unmounts the whole tree, leaving a blank window. + const logUncaught = (kind, err) => { + window.electronUI?.log(`--------------[UI ${kind}]--------------- + ${parseConsoleArgs([err])} + ------------[UI End]----------------`); + }; + window.addEventListener('error', (event) => { + logUncaught('uncaught error', event.error ?? event.message); + }); + window.addEventListener('unhandledrejection', (event) => { + logUncaught('unhandled rejection', event.reason); + }); } try { require(