mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
chore: improve renderer crash logging (#25621)
Co-authored-by: Milan Burda <milan.burda@gmail.com>
This commit is contained in:
@@ -468,8 +468,7 @@ const addReturnValueToEvent = (event) => {
|
||||
};
|
||||
|
||||
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.
|
||||
@@ -538,17 +537,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.reload();
|
||||
|
||||
Reference in New Issue
Block a user