fix(desktop): harden cancellation, dispose, and lifecycle races across main services
Cancel pending result-popup measure timers on hideResultPopup; track CaptionService aux-model load state, stop deduplication, and refine abort epochs across restarts; forward per-call AbortSignal through VoiceModeService and LlmGateway to LocalLLMService and abort pull streams plus availability polling on dispose; clear aborted response pointers and gate stale mic start errors in VoiceConversationService; guard AudioCaptureService stopping resume against exited SoX processes and cleanup failed starts; abort LocalSTTService downloadModel polling on dispose; and fail closed when desktopCapturer.getSources rejects in caption loopback setup.
This commit is contained in:
parent
4bf0f0df12
commit
fc5d45312c
19 changed files with 922 additions and 94 deletions
|
|
@ -374,4 +374,54 @@ describe('LocalSTTService — 사이드카 크래시 재시작', () => {
|
|||
expect(local.currentModelId).toBe('tiny')
|
||||
await local.dispose()
|
||||
})
|
||||
|
||||
it('downloadModel_disposedWhilePolling_abortsPromptlyWithoutPollingAfterDispose', async () => {
|
||||
const h = createHarness()
|
||||
h.setHealthy(true)
|
||||
let statusPollsAfterDispose = 0
|
||||
let disposed = false
|
||||
|
||||
const wrappedFetch = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const url = String(input)
|
||||
if (url.endsWith('/download')) {
|
||||
return jsonResponse({ status: 'downloading' })
|
||||
}
|
||||
if (url.endsWith('/download/status')) {
|
||||
if (disposed) {
|
||||
statusPollsAfterDispose++
|
||||
if (statusPollsAfterDispose >= 2) {
|
||||
return jsonResponse({
|
||||
status: 'done',
|
||||
percent: 100,
|
||||
downloaded_bytes: 100,
|
||||
total_bytes: 100,
|
||||
bytes_per_second: 100,
|
||||
})
|
||||
}
|
||||
}
|
||||
return jsonResponse({
|
||||
status: 'downloading',
|
||||
percent: 10,
|
||||
downloaded_bytes: 10,
|
||||
total_bytes: 100,
|
||||
bytes_per_second: 10,
|
||||
})
|
||||
}
|
||||
return h.fetch(url, init)
|
||||
})
|
||||
vi.stubGlobal('fetch', wrappedFetch)
|
||||
|
||||
const local = new LocalSTTService({ supervisor: h.supervisor })
|
||||
const downloadPromise = local.downloadModel('tiny')
|
||||
await vi.waitFor(() =>
|
||||
expect(wrappedFetch.mock.calls.some(([url]) => String(url).endsWith('/download'))).toBe(true),
|
||||
)
|
||||
|
||||
disposed = true
|
||||
const disposePromise = local.dispose()
|
||||
|
||||
await expect(downloadPromise).rejects.toMatchObject({ code: ErrorCode.STTModelDownloadCancelled })
|
||||
await disposePromise
|
||||
expect(statusPollsAfterDispose).toBe(0)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue