MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / closeWorkerAsync

Function closeWorkerAsync

apps/desktop/main/worker/workerManager.ts:284–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

282 * 用于应用退出前的清理,确保 Worker 完全关闭
283 */
284export async function closeWorkerAsync(): Promise<void> {
285 if (worker) {
286 console.log('[WorkerManager] Closing worker async...')
287 try {
288 // 等待关闭所有数据库连接(最多等待 3 秒)
289 await Promise.race([sendToWorker('closeAll', {}), new Promise((resolve) => setTimeout(resolve, 3000))])
290 } catch {
291 // 忽略错误,继续终止
292 }
293
294 worker.terminate()
295 worker = null
296 rejectAllPending(new Error('Worker terminated'))
297 console.log('[WorkerManager] Worker terminated (async)')
298 }
299}
300
301// ==================== 通用查询 API ====================
302

Callers 1

checkUpdateFunction · 0.90

Calls 4

sendToWorkerFunction · 0.85
setTimeoutFunction · 0.85
rejectAllPendingFunction · 0.85
terminateMethod · 0.65

Tested by

no test coverage detected