perf+fix: sprint B — async I/O, before-quit, immutable getState, lucide tree-shake
#2 atomicWrite spin-loop → async setTimeout. Раньше при retry на EBUSY/EPERM (антивирус, OneDrive) main process замораживался на 50/200/800ms × до 3 итераций ≈ секунда залипания UI. Сейчас async sleep — event-loop живёт. Сохранён atomicWriteSync для flushNow (вызывается из before-quit когда event-loop уже умирает). Аналогичный фикс в games/steam-launch-options.ts. #5 before-quit теперь дожидается stopGamesRegistry через e.preventDefault() + app.exit(0). Раньше GSI HTTP server не успевал closeAllConnections до exit, и следующий запуск получал EADDRINUSE на port 4701 (TIME_WAIT) — GSI молча не работал. #10 IPC.getState возвращает поверхностную копию settings вместо мутации кэша. Раньше startWithWindows писалось напрямую в state.settings, разъезжаясь с persisted-disk-значением до следующего mutation. #19 lib/icon.tsx: `import * as Lucide` (wildcard, ~500KB в bundle, 1500+ иконок) → explicit named imports + ICON_MAP. В bundle остаются только 18 ICON_CHOICES.
This commit is contained in:
@@ -73,11 +73,26 @@ if (!gotLock) {
|
||||
}
|
||||
})
|
||||
|
||||
app.on('before-quit', () => {
|
||||
// Перехватываем первый before-quit, чтобы дождаться `stopGamesRegistry`
|
||||
// (закрывает GSI HTTP server со всеми pending connections). Без этого
|
||||
// следующий запуск получает EADDRINUSE на port 4701 (TIME_WAIT), и
|
||||
// GSI молча не работает. После cleanup'а — реально quit.
|
||||
let quitting = false
|
||||
app.on('before-quit', (e) => {
|
||||
if (quitting) return
|
||||
e.preventDefault()
|
||||
quitting = true
|
||||
stopScheduler()
|
||||
stopUpdater()
|
||||
void stopGamesRegistry()
|
||||
flushNow()
|
||||
void (async () => {
|
||||
try {
|
||||
await stopGamesRegistry()
|
||||
} catch (err) {
|
||||
console.error('[index] stopGamesRegistry threw:', err)
|
||||
}
|
||||
flushNow()
|
||||
app.exit(0)
|
||||
})()
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
|
||||
Reference in New Issue
Block a user