chore: improve renderer crash logging (#25592)
This commit is contained in:
		
					parent
					
						
							
								dcd6e1f2b8
							
						
					
				
			
			
				commit
				
					
						1f856c25a9
					
				
			
		
					 1 changed files with 6 additions and 7 deletions
				
			
		|  | @ -462,8 +462,7 @@ 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')); | ||||
|   return process.env.ELECTRON_ENABLE_LOGGING || app.commandLine.hasSwitch('enable-logging'); | ||||
| }; | ||||
| 
 | ||||
| // Add JavaScript wrappers for WebContents class.
 | ||||
|  | @ -548,17 +547,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: Electron.WebContentsInternal) { | ||||
|     this.reload(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Milan Burda
				Milan Burda