Skip to content

Commit

Permalink
chore: log hint on renderer crash (#25473)
Browse files Browse the repository at this point in the history
* chore: log hint on renderer crash

* Address feedback from review

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Sep 15, 2020
1 parent fe3378d commit 81c1a6e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/browser/api/web-contents.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 81c1a6e

Please sign in to comment.