mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 00:41:39 +08:00
fix(electron): potential crash on quit (#8855)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { app } from 'electron';
|
||||
|
||||
import { logger } from './logger';
|
||||
|
||||
const cleanupRegistry: (() => void)[] = [];
|
||||
|
||||
export function beforeAppQuit(fn: () => void) {
|
||||
cleanupRegistry.push(fn);
|
||||
}
|
||||
|
||||
app.on('before-quit', () => {
|
||||
cleanupRegistry.forEach(fn => {
|
||||
// some cleanup functions might throw on quit and crash the app
|
||||
try {
|
||||
fn();
|
||||
} catch (err) {
|
||||
logger.warn('cleanup error on quit', err);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user