Browse Source

chore: log hint on renderer crash (#25474)

* chore: log hint on renderer crash

* Address feedback from review

Co-authored-by: Shelley Vohr <[email protected]>
trop[bot] 4 years ago
parent
commit
c1d04d8e49
1 changed files with 10 additions and 0 deletions
  1. 10 0
      lib/browser/api/web-contents.ts

+ 10 - 0
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.
@@ -543,6 +548,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) => {