종료 시 'Tray is destroyed' 오류 창: 트레이 · 상태 갱신 타이머를 멈추고 트레이를 비운 뒤 없앤다 · Electron 이 먼저 없앤 트레이도 건드리지 않음 · 종료 중 STT 는 새 작업을 꺼내지 않고 워커 종료로 실패한 작업을 닫힌 DB 에 기록하지 않음 (시험 추가)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -189,6 +189,7 @@ export async function startCore(opts: CoreOptions) {
|
||||
relay.stop();
|
||||
retention.stop();
|
||||
games.stop();
|
||||
stt.stop();
|
||||
await bot.stop();
|
||||
await worker.stop();
|
||||
await api.close();
|
||||
|
||||
@@ -81,6 +81,8 @@ export class SttPipeline {
|
||||
private queued = new Set<string>();
|
||||
private busy = false;
|
||||
private processing: string | null = null;
|
||||
/** 앱 종료 중: 새 작업을 꺼내지 않고, 워커가 끊겨 실패한 작업은 DB(곧 닫힘)에 기록하지 않는다. 남은 발화는 다음 시작 때 다시 처리 */
|
||||
private stopped = false;
|
||||
/** 한 발화의 변환이 끝났을 때 (녹음 파일 이름 맞추기) */
|
||||
onDone: ((id: string) => void) | null = null;
|
||||
/** 예전 녹음 고치기가 끝났을 때 */
|
||||
@@ -238,8 +240,13 @@ export class SttPipeline {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 종료 시작 (워커 · DB 를 닫기 전에 부른다) */
|
||||
stop(): void {
|
||||
this.stopped = true;
|
||||
}
|
||||
|
||||
private pump(): void {
|
||||
if (this.busy || !this.worker.ready) return;
|
||||
if (this.stopped || this.busy || !this.worker.ready) return;
|
||||
const idx = this.queue.findIndex((j) => this.pickSlot(j) !== null);
|
||||
if (idx < 0) return;
|
||||
const job = this.queue.splice(idx, 1)[0];
|
||||
@@ -254,6 +261,7 @@ export class SttPipeline {
|
||||
this.busy = false;
|
||||
this.processing = null;
|
||||
this.status.processing = null;
|
||||
if (this.stopped) return;
|
||||
try {
|
||||
if (!this.isBusy(job.id)) this.onDone?.(job.id);
|
||||
} catch (e) {
|
||||
@@ -320,6 +328,7 @@ export class SttPipeline {
|
||||
5 * 60000,
|
||||
);
|
||||
} catch (e: any) {
|
||||
if (this.stopped) return;
|
||||
const attempts = this.store.bumpAttempt(u.id);
|
||||
this.status.lastError = e.message;
|
||||
log.warn(`STT 실패 (${u.id}, ${attempts}회): ${e.message}`);
|
||||
|
||||
@@ -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('녹음 · 음성 인식 엔진 시작 중…');
|
||||
|
||||
Reference in New Issue
Block a user