From 81c1a6ed29a0907bf9c61ae951b9d55a95081457 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 15 Sep 2020 14:01:31 -0600 Subject: [PATCH] chore: log hint on renderer crash (#25473) * chore: log hint on renderer crash * Address feedback from review Co-authored-by: Shelley Vohr --- lib/browser/api/web-contents.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 3e4efe716a825..c5abb4388eb37 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -459,6 +459,11 @@ const addReturnValueToEvent = (event) => { }); }; +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. @@ -525,6 +530,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 (loggingEnabled()) { + console.info('Renderer process crashed - see https://www.electronjs.org/docs/tutorial/application-debugging for potential debugging information.'); + } }); this.on('render-process-gone', (event, ...args) => {