Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log hint on renderer crash #25317

Merged
merged 2 commits into from Sep 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/browser/api/web-contents.ts
Expand Up @@ -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'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use app.commandLine to check this sort of thing.

Suggested change
process.argv.some(arg => arg.toLowerCase().startsWith('--enable-logging'));
app.commandLine.hasSwitch('enable-logging')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};

// Add JavaScript wrappers for WebContents class.
WebContents.prototype._init = function () {
// The navigation controller.
Expand Down Expand Up @@ -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.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we give some more info about the crash here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
});

this.on('render-process-gone', (event, ...args) => {
Expand Down