종료 시 'Tray is destroyed' 오류 창: 트레이 · 상태 갱신 타이머를 멈추고 트레이를 비운 뒤 없앤다 · Electron 이 먼저 없앤 트레이도 건드리지 않음 · 종료 중 STT 는 새 작업을 꺼내지 않고 워커 종료로 실패한 작업을 닫힌 DB 에 기록하지 않음 (시험 추가)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-18 23:25:25 +09:00
parent dc36d094e9
commit cd4b7cb16f
4 changed files with 79 additions and 8 deletions

View File

@@ -34,6 +34,8 @@ let settings: SettingsStore | null = null;
let auth: AppAuth | null = null;
let win: BrowserWindow | null = null;
let tray: Tray | null = null;
/** 트레이 · 상태 갱신 타이머 (종료할 때 멈춘다) */
const timers: NodeJS.Timeout[] = [];
let quitting = false;
const dataDir = resolveDataDir(opt('data-dir'));
@@ -148,7 +150,8 @@ function closeSplash(): void {
}
function updateTray(): void {
if (!tray) return;
// Windows 로그오프 등으로 Electron 이 트레이를 먼저 없앤 경우에도 오류 창이 뜨지 않게
if (!tray || tray.isDestroyed()) return;
if (!core) {
tray.setImage(trayImage('off'));
tray.setToolTip(`겜녹이\n${auth?.state.status === 'not_registered' ? '등록되지 않은 아이디' : '로그인이 필요합니다'}`);
@@ -168,7 +171,7 @@ function updateTray(): void {
}
function buildTrayMenu(): void {
if (!tray) return;
if (!tray || tray.isDestroyed()) return;
if (!core) {
tray.setContextMenu(
Menu.buildFromTemplate([
@@ -203,7 +206,11 @@ async function quit(): Promise<void> {
} catch (e) {
log.error('종료 중 오류', e);
}
tray?.destroy();
// 트레이 갱신 타이머가 app.exit 사이에 한 번 더 돌면 'Tray is destroyed' 오류 창이 뜬다
for (const t of timers) clearInterval(t);
const tr = tray;
tray = null;
tr?.destroy();
app.exit(0);
}
@@ -383,18 +390,18 @@ app.whenReady().then(async () => {
// 시작할 때 확인 → 10분마다 다시 확인 (등록 해제되면 바로 잠김). 서버에 못 붙어 막힌 상태면 1분마다 다시 시도
let lastCheck = Date.now();
const first = a.check();
setInterval(() => {
timers.push(setInterval(() => {
const st = a.state.status;
if ((st === 'ok' && Date.now() - lastCheck > 10 * 60000) || (st === 'error' && Date.now() - lastCheck > 60000) || (st === 'ok' && a.state.offline && Date.now() - lastCheck > 60000)) {
lastCheck = Date.now();
void a.check().then(syncNames);
}
}, 15000);
setInterval(() => {
}, 15000));
timers.push(setInterval(() => {
updateTray();
buildTrayMenu();
pushState();
}, 1500);
}, 1500));
splashText('로그인 확인 중…');
await first;
if (a.ok) splashText('녹음 · 음성 인식 엔진 시작 중…');