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: remove deprecated crashReporter APIs #26709

Merged
Show file tree
Hide file tree
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
16 changes: 5 additions & 11 deletions docs/api/crash-reporter.md
Expand Up @@ -128,7 +128,7 @@ must be at most 39 bytes long, and values must be no longer than 127 bytes.
Keys with names longer than the maximum will be silently ignored. Key values
longer than the maximum length will be truncated.

**Note:** Calling this method from the renderer process is deprecated.
**Note:** This method is only available in the main process.

### `crashReporter.getLastCrashReport()`

Expand All @@ -137,7 +137,7 @@ last crash report. Only crash reports that have been uploaded will be returned;
even if a crash report is present on disk it will not be returned until it is
uploaded. In the case that there are no uploaded reports, `null` is returned.

**Note:** Calling this method from the renderer process is deprecated.
**Note:** This method is only available in the main process.

### `crashReporter.getUploadedReports()`

Expand All @@ -146,14 +146,14 @@ Returns [`CrashReport[]`](structures/crash-report.md):
Returns all uploaded crash reports. Each report contains the date and uploaded
ID.

**Note:** Calling this method from the renderer process is deprecated.
**Note:** This method is only available in the main process.

### `crashReporter.getUploadToServer()`

Returns `Boolean` - Whether reports should be submitted to the server. Set through
the `start` method or `setUploadToServer`.

**Note:** Calling this method from the renderer process is deprecated.
**Note:** This method is only available in the main process.

### `crashReporter.setUploadToServer(uploadToServer)`

Expand All @@ -162,13 +162,7 @@ the `start` method or `setUploadToServer`.
This would normally be controlled by user preferences. This has no effect if
called before `start` is called.

**Note:** Calling this method from the renderer process is deprecated.

### `crashReporter.getCrashesDirectory()` _Deprecated_

Returns `String` - The directory where crashes are temporarily stored before being uploaded.

**Note:** This method is deprecated, use `app.getPath('crashDumps')` instead.
**Note:** This method is only available in the main process.

### `crashReporter.addExtraParameter(key, value)`

Expand Down
12 changes: 12 additions & 0 deletions docs/breaking-changes.md
Expand Up @@ -43,6 +43,18 @@ We [recommend having contextIsolation enabled](https://github.com/electron/elect

For more details see: https://github.com/electron/electron/issues/23506

### Removed: `crashReporter.getCrashesDirectory()`

The `crashReporter.getCrashesDirectory` method has been removed. Usage
should be replaced by `app.getPath('crashDumps')`.

```js
// Removed in Electron 12
crashReporter.getCrashesDirectory()
// Replace with
app.getPath('crashDumps')
```

### Removed: `crashReporter` methods in the renderer process

The following `crashReporter` methods are no longer available in the renderer
Expand Down
4 changes: 0 additions & 4 deletions lib/browser/api/crash-reporter.ts
Expand Up @@ -51,10 +51,6 @@ class CrashReporter {
return binding.getUploadedReports();
}

getCrashesDirectory () {
return app.getPath('crashDumps');
}

getUploadToServer () {
if (process.type === 'browser') {
return binding.getUploadToServer();
Expand Down
22 changes: 1 addition & 21 deletions lib/browser/rpc-server.ts
@@ -1,6 +1,6 @@
import { app } from 'electron/main';
import type { WebContents } from 'electron/main';
import { clipboard, crashReporter, nativeImage } from 'electron/common';
import { clipboard, nativeImage } from 'electron/common';
import * as fs from 'fs';
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
Expand Down Expand Up @@ -114,26 +114,6 @@ ipcMainInternal.on(IPC_MESSAGES.BROWSER_PRELOAD_ERROR, function (event, preloadP
event.sender.emit('preload-error', event, preloadPath, error);
});

ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_LAST_CRASH_REPORT, () => {
return crashReporter.getLastCrashReport();
});

ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOADED_REPORTS, () => {
return crashReporter.getUploadedReports();
});

ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOAD_TO_SERVER, () => {
return crashReporter.getUploadToServer();
});

ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_SET_UPLOAD_TO_SERVER, (event, uploadToServer: boolean) => {
return crashReporter.setUploadToServer(uploadToServer);
});

ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_CRASHES_DIRECTORY, () => {
return crashReporter.getCrashesDirectory();
});

ipcMainInternal.handle(IPC_MESSAGES.NATIVE_IMAGE_CREATE_THUMBNAIL_FROM_PATH, async (_, path: string, size: Electron.Size) => {
return typeUtils.serialize(await nativeImage.createThumbnailFromPath(path, size));
});
6 changes: 0 additions & 6 deletions lib/common/ipc-messages.ts
Expand Up @@ -5,12 +5,6 @@ export const enum IPC_MESSAGES {
BROWSER_SANDBOX_LOAD = 'BROWSER_SANDBOX_LOAD',
BROWSER_WINDOW_CLOSE = 'BROWSER_WINDOW_CLOSE',

CRASH_REPORTER_GET_LAST_CRASH_REPORT = 'CRASH_REPORTER_GET_LAST_CRASH_REPORT',
CRASH_REPORTER_GET_UPLOADED_REPORTS = 'CRASH_REPORTER_GET_UPLOADED_REPORTS',
CRASH_REPORTER_GET_UPLOAD_TO_SERVER = 'CRASH_REPORTER_GET_UPLOAD_TO_SERVER',
CRASH_REPORTER_SET_UPLOAD_TO_SERVER = 'CRASH_REPORTER_SET_UPLOAD_TO_SERVER',
CRASH_REPORTER_GET_CRASHES_DIRECTORY = 'CRASH_REPORTER_GET_CRASHES_DIRECTORY',

GUEST_INSTANCE_VISIBILITY_CHANGE = 'GUEST_INSTANCE_VISIBILITY_CHANGE',

GUEST_VIEW_INTERNAL_DESTROY_GUEST = 'GUEST_VIEW_INTERNAL_DESTROY_GUEST',
Expand Down
36 changes: 0 additions & 36 deletions lib/renderer/api/crash-reporter.ts
@@ -1,42 +1,6 @@
import { invokeSync } from '../ipc-renderer-internal-utils';
import { deprecate } from 'electron';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';

const binding = process._linkedBinding('electron_renderer_crash_reporter');

export default {
start (options: Electron.CrashReporterStartOptions) {
deprecate.log('crashReporter.start is deprecated in the renderer process. Call it from the main process instead.');
for (const [k, v] of Object.entries(options.extra || {})) {
binding.addExtraParameter(k, String(v));
}
},

getLastCrashReport (): Electron.CrashReport | null {
deprecate.log('crashReporter.getLastCrashReport is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_LAST_CRASH_REPORT);
},

getUploadedReports () {
deprecate.log('crashReporter.getUploadedReports is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOADED_REPORTS);
},

getUploadToServer () {
deprecate.log('crashReporter.getUploadToServer is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOAD_TO_SERVER);
},

setUploadToServer (uploadToServer: boolean) {
deprecate.log('crashReporter.setUploadToServer is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_SET_UPLOAD_TO_SERVER, uploadToServer);
},

getCrashesDirectory () {
deprecate.log('crashReporter.getCrashesDirectory is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_CRASHES_DIRECTORY);
},

addExtraParameter (key: string, value: string) {
binding.addExtraParameter(key, value);
},
Expand Down
10 changes: 3 additions & 7 deletions spec-main/api-crash-reporter-spec.ts
Expand Up @@ -523,10 +523,6 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
expect(app.getPath('crashDumps')).to.include(app.getPath('userData'));
});

it('matches getCrashesDirectory', async () => {
expect(app.getPath('crashDumps')).to.equal(require('electron').crashReporter.getCrashesDirectory());
});

function crash (processType: string, remotely: Function) {
if (processType === 'main') {
return remotely(() => {
Expand Down Expand Up @@ -565,9 +561,9 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
it('stores crashes in the crash dump directory when uploadToServer: false', async () => {
const { remotely } = await startRemoteControlApp();
const crashesDir = await remotely(() => {
const { crashReporter } = require('electron');
const { crashReporter, app } = require('electron');
crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true });
return crashReporter.getCrashesDirectory();
return app.getPath('crashDumps');
});
let reportsDir = crashesDir;
if (process.platform === 'darwin') {
Expand Down Expand Up @@ -599,7 +595,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
const { crashReporter, app } = require('electron');
app.setPath('crashDumps', crashesDir);
crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true });
return crashReporter.getCrashesDirectory();
return app.getPath('crashDumps');
}, crashesDir);
expect(remoteCrashesDir).to.equal(crashesDir);

Expand Down