From c77e08f428c7aae1b6570e6942ddf5ff8fdd2733 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 3 Sep 2020 18:41:32 -0700 Subject: [PATCH 1/2] chore: log hint on renderer crash --- lib/browser/api/web-contents.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index f4c30bfc7ac42..afd255a10c5dd 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -543,6 +543,11 @@ WebContents.prototype._init = function () { this.on('crashed', (event, ...args) => { app.emit('renderer-process-crashed', event, this, ...args); + + // Log out a hint to help users better debug renderer crashes. + if (!process.env.ELECTRON_ENABLE_LOGGING) { + console.info('Renderer process crashed - setting ELECTRON_ENABLE_LOGGING may provide more information.'); + } }); this.on('render-process-gone', (event, ...args) => { From decf4cddb87087230374fa051f62d2a4a4494b7d Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 14 Sep 2020 08:58:07 -0600 Subject: [PATCH 2/2] Address feedback from review --- lib/browser/api/web-contents.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index afd255a10c5dd..c9986ea5f96b4 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -461,6 +461,11 @@ const addReturnValueToEvent = (event: any) => { }); }; +const loggingEnabled = () => { + return Object.prototype.hasOwnProperty.call(process.env, 'ELECTRON_ENABLE_LOGGING') || + process.argv.some(arg => arg.toLowerCase().startsWith('--enable-logging')); +}; + // Add JavaScript wrappers for WebContents class. WebContents.prototype._init = function () { // The navigation controller. @@ -545,8 +550,8 @@ WebContents.prototype._init = function () { app.emit('renderer-process-crashed', event, this, ...args); // Log out a hint to help users better debug renderer crashes. - if (!process.env.ELECTRON_ENABLE_LOGGING) { - console.info('Renderer process crashed - setting ELECTRON_ENABLE_LOGGING may provide more information.'); + if (loggingEnabled()) { + console.info('Renderer process crashed - see https://www.electronjs.org/docs/tutorial/application-debugging for potential debugging information.'); } });