Submit crash reports to a remote server.

进程: Main, renderer 进程


const {crashReporter} = require('electron')

  productName: 'YourName',
  companyName: 'YourCompany',
  submitURL: '',
  uploadToServer: true


Crash reports are saved locally in an application-specific temp directory folder. For a productName of YourName, crash reports will be stored in a folder named YourName Crashes inside the temp directory. You can customize this temp directory location for your app by calling the app.setPath('temp', '/my/custom/temp') API before starting the crash reporter.


The crashReporter module has the following methods:


  • options Object
    • companyName String (optional)
    • submitURL String - URL that crash reports will be sent to as POST.
    • productName String (optional) - Defaults to app.getName().
    • uploadToServer Boolean (optional) - Whether crash reports should be sent to the server Default is true.
    • ignoreSystemCrashHandler Boolean (optional) - Default is false.
    • extra Object (optional) - An object you can define that will be sent along with the report. Only string properties are sent correctly. Nested objects are not supported and the property names and values must be less than 64 characters long.

You are required to call this method before using any other crashReporter APIs and in each process (main/renderer) from which you want to collect crash reports. You can pass different options to crashReporter.start when calling from different processes.

Note Child processes created via the child_process module will not have access to the Electron modules. Therefore, to collect crash reports from them, use process.crashReporter.start instead. Pass the same options as above along with an additional one called crashesDirectory that should point to a directory to store the crash reports temporarily. You can test this out by calling process.crash() to crash the child process.

Note: To collect crash reports from child process in Windows, you need to add this extra code as well. This will start the process that will monitor and send the crash reports. Replace submitURL, productName and crashesDirectory with appropriate values.

Note: If you need send additional/updated extra parameters after your first call start you can call setExtraParameter on macOS or call start again with the new/updated extra parameters on Linux and Windows.

 const args = [
 const env = {
 spawn(process.execPath, args, {
   env: env,
   detached: true

Note: On macOS, Electron uses a new crashpad client for crash collection and reporting. If you want to enable crash reporting, initializing crashpad from the main process using crashReporter.start is required regardless of which process you want to collect crashes from. Once initialized this way, the crashpad handler collects crashes from all processes. You still have to call crashReporter.start from the renderer or child process, otherwise crashes from them will get reported without companyName, productName or any of the extra information.


Returns CrashReport:

Returns the date and ID of the last crash report. If no crash reports have been sent or the crash reporter has not been started, null is returned.


Returns CrashReport[]:

Returns all uploaded crash reports. Each report contains the date and uploaded ID.


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

Note: This API can only be called from the main process.


  • uploadToServer Boolean macOS - Whether reports should be submitted to the server

This would normally be controlled by user preferences. This has no effect if called before start is called.

Note: This API can only be called from the main process.

crashReporter.setExtraParameter(key, value)macOS

  • key String - Parameter key, must be less than 64 characters long.
  • value String - Parameter value, must be less than 64 characters long. Specifying null or undefined will remove the key from the extra parameters.

Set an extra parameter to be sent with the crash report. The values specified here will be sent in addition to any values set via the extra option when start was called. This API is only available on macOS, if you need to add/update extra parameters on Linux and Windows after your first call to start you can call start again with the updated extra options.

Crash Report Payload

The crash reporter will send the following data to the submitURL as a multipart/form-dataPOST:

  • ver String - The version of Electron.
  • platform String - e.g. 'win32'.
  • process_type String - e.g. 'renderer'.
  • guid String - e.g. '5e1286fc-da97-479e-918b-6bfb0c3d1c72'
  • _version String - The version in package.json.
  • _productName String - The product name in the crashReporteroptions object.
  • prod String - Name of the underlying product. In this case Electron.
  • _companyName String - The company name in the crashReporteroptions object.
  • upload_file_minidump File - The crash report in the format of minidump.
  • All level one properties of the extra object in the crashReporteroptions object.









  • 如何深入理解electron-vue的build构建命令
  • electron-packager如何正确处理第三方资源的打包问题
  • JS开发者社区


    新手/专属新手 685983304
    中级/30元中级 642625556
    高级/50元高级 602866851
    PHP/福利PHP 218127186


    售前专员会在一到两个工作日内,评估难度并回复报价。 点击这里给我发消息1833669936