From c32cb09a68624bdc86b4daeedb6406c90ebc2749 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 24 Sep 2020 12:55:54 -0700 Subject: [PATCH] chore: improve renderer crash logging (#25620) Co-authored-by: Milan Burda --- lib/browser/api/web-contents.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index c5abb4388eb37..379fc5a4b4438 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -460,8 +460,7 @@ const addReturnValueToEvent = (event) => { }; const loggingEnabled = () => { - return Object.prototype.hasOwnProperty.call(process.env, 'ELECTRON_ENABLE_LOGGING') || - process.argv.some(arg => arg.toLowerCase().startsWith('--enable-logging')); + return process.env.ELECTRON_ENABLE_LOGGING || app.commandLine.hasSwitch('enable-logging'); }; // Add JavaScript wrappers for WebContents class. @@ -530,17 +529,17 @@ WebContents.prototype._init = function () { this.on('crashed', (event, ...args) => { app.emit('renderer-process-crashed', event, this, ...args); + }); + + this.on('render-process-gone', (event, details) => { + app.emit('render-process-gone', event, this, details); // Log out a hint to help users better debug renderer crashes. if (loggingEnabled()) { - console.info('Renderer process crashed - see https://www.electronjs.org/docs/tutorial/application-debugging for potential debugging information.'); + console.info(`Renderer process ${details.reason} - see https://www.electronjs.org/docs/tutorial/application-debugging for potential debugging information.`); } }); - this.on('render-process-gone', (event, ...args) => { - app.emit('render-process-gone', event, this, ...args); - }); - // The devtools requests the webContents to reload. this.on('devtools-reload-page', function () { this.reload();