mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: correctly crash when there is no crashReporter (#20395)
* fix: correctly crash when there is no crashReporter * test: correctly crash when there is crashReporter
This commit is contained in:
committed by
John Kleinschmidt
parent
1f660c67c6
commit
312f14ee88
@@ -28,9 +28,17 @@ namespace {
|
||||
#if defined(_WIN64)
|
||||
int CrashForException(EXCEPTION_POINTERS* info) {
|
||||
auto* reporter = crash_reporter::CrashReporterWin::GetInstance();
|
||||
if (reporter->IsInitialized())
|
||||
if (reporter->IsInitialized()) {
|
||||
reporter->GetCrashpadClient().DumpAndCrash(info);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
// When there is exception and we do not have crashReporter set up, we just
|
||||
// let the execution continue and crash, which is the default behavior.
|
||||
//
|
||||
// We must not return EXCEPTION_CONTINUE_SEARCH here, as it would end up with
|
||||
// busy loop when there is no exception handler in the program.
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -415,6 +415,16 @@ describe('crashReporter module', () => {
|
||||
expect(crashReporter.getParameters()).to.not.have.a.property('hello')
|
||||
})
|
||||
})
|
||||
|
||||
describe('when not started', () => {
|
||||
it('does not prevent process from crashing', (done) => {
|
||||
const appPath = path.join(fixtures, 'api', 'cookie-app')
|
||||
const appProcess = childProcess.spawn(process.execPath, [appPath])
|
||||
appProcess.once('close', () => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const waitForCrashReport = () => {
|
||||
|
||||
5
spec/fixtures/crash-app/main.js
vendored
Normal file
5
spec/fixtures/crash-app/main.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
const { app } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
process.crash()
|
||||
})
|
||||
4
spec/fixtures/crash-app/package.json
vendored
Normal file
4
spec/fixtures/crash-app/package.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "electron-crash-app",
|
||||
"main": "main.js"
|
||||
}
|
||||
Reference in New Issue
Block a user