@@ -21,7 +21,7 @@ import {
21
21
} from 'electron' ;
22
22
23
23
import crypto from 'crypto' ;
24
- import fs , { appendFileSync } from 'fs' ;
24
+ import fs from 'fs' ;
25
25
import os from 'os' ;
26
26
import path , { join } from 'path' ;
27
27
import { platform as osPlatform } from 'process' ;
@@ -153,8 +153,23 @@ if (!process.mas) {
153
153
}
154
154
}
155
155
156
+ /**
157
+ * Starts the crash reporter, which saves crashes to disk.
158
+ * The dumps will be saved in the `userData/CrashPad/pending` directory.
159
+ *
160
+ * The minidumps can be read using the `minidump_stackwalk` tool.
161
+ * If you do not have cargo installed, you can do those steps:
162
+ * ```bash
163
+ * git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
164
+ * cd depot_tools
165
+ * mkdir breakpad && cd breakpad
166
+ * ../fetch breakpad && cd src
167
+ * ./configure && make
168
+ * file src/processor/minidump_stackwalk
169
+ * ./src/processor/minidump_stackwalk <path_to.dmp> <any_symbols_you_have_optional>
170
+ */
156
171
crashReporter . start ( {
157
- submitURL : '' , // leave empty if you don’ t want to upload
172
+ submitURL : '' , // leave empty as we don' t want to upload them, but only save them locally
158
173
uploadToServer : false ,
159
174
compress : true ,
160
175
} ) ;
@@ -185,6 +200,8 @@ import * as log from '../util/logger/log';
185
200
import { DURATION } from '../session/constants' ;
186
201
import { tr } from '../localization/localeTools' ;
187
202
203
+ import { logCrash } from '../node/crash/log_crash' ;
204
+
188
205
function prepareURL ( pathSegments : Array < string > , moreKeys ?: { theme : any } ) {
189
206
const urlObject : url . UrlObject = {
190
207
pathname : join ( ...pathSegments ) ,
@@ -367,11 +384,6 @@ async function createWindow() {
367
384
mainWindow . on ( 'focus' , setWindowFocus ) ;
368
385
mainWindow . on ( 'blur' , setWindowFocus ) ;
369
386
mainWindow . once ( 'ready-to-show' , setWindowFocus ) ;
370
- function logCrash ( type : string , details : any ) {
371
- const crashLogPath = path . join ( app . getPath ( 'userData' ) , 'crash-log.txt' ) ;
372
- const logLine = `[${ new Date ( ) . toISOString ( ) } ] ${ type } crash: ${ JSON . stringify ( details ) } \n` ;
373
- appendFileSync ( crashLogPath , logLine , 'utf8' ) ;
374
- }
375
387
376
388
mainWindow . webContents . on ( 'render-process-gone' , ( _event , details ) => {
377
389
// details.reason can be: 'crashed', 'killed', 'oom', etc.
0 commit comments