{"record":{"id":"09af8100033e3e65","repo":"mihomo-party-org/clash-party","slug":"core-is-not-running-restarting-core-instead-of-ho","errorCode":null,"errorMessage":"Core is not running, restarting core instead of hot reload","messagePattern":"Core is not running, restarting core instead of hot reload","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/main/core/mihomoApi.ts","lineNumber":433,"sourceCode":"      timeout: delayTestTimeout || 5000\n    }\n  })\n}\n\nexport const mihomoUpgrade = async (): Promise<void> => {\n  const instance = await getAxios()\n  return await instance.post('/upgrade', undefined, { timeout: 90000 })\n}\n\nexport const mihomoUpgradeUI = async (): Promise<void> => {\n  const instance = await getAxios()\n  return await instance.post('/upgrade/ui')\n}\n\nexport const mihomoHotReloadConfig = async (): Promise<void> => {\n  mihomoApiLogger.info('mihomoHotReloadConfig called')\n  if (!hasCoreProcess()) {\n    mihomoApiLogger.warn('Core is not running, restarting core instead of hot reload')\n    await restartCore()\n    return\n  }\n  const current = await generateProfile()\n  const { diffWorkDir = false } = await getAppConfig()\n  const configPath = diffWorkDir ? mihomoWorkConfigPath(current) : mihomoWorkConfigPath('work')\n  mihomoApiLogger.info(`hot reload config path: ${configPath}`)\n  const instance = await getAxios()\n  try {\n    await instance.put('/configs?force=true', { path: configPath })\n  } catch (error) {\n    if (hasCoreProcess()) throw error\n    mihomoApiLogger.warn('Core exited before hot reload completed, restarting core', error)\n    await restartCore()\n    return\n  }\n  mihomoApiLogger.info('hot reload config completed')\n  try {","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/mihomo-party-org/clash-party/blob/911e090537acdf7c50bee1c3aebecc2ef119a8b5/src/main/core/mihomoApi.ts#L415-L451","documentation":"mihomoHotReloadConfig logs this warning when the mihomo core process is not running (hasCoreProcess() returns false), so a hot reload via the /configs API is impossible. Instead of failing, it degrades gracefully by calling restartCore(), which boots a fresh core with the regenerated profile. It is a diagnostic breadcrumb, not a thrown exception.","triggerScenarios":"Calling mihomoHotReloadConfig() after the core process crashed, was manually stopped, or before the core was ever started (e.g. app startup race where config changes are applied before coreStartPromise resolves).","commonSituations":"Core crashed due to a bad config or port conflict and the UI triggers a config save; user toggles a setting while mihomo was stopped; a race during app init where profile edits happen before the core spawns.","solutions":["Start the core first (await startCore / resolve the coreStartPromise) before calling mihomoHotReloadConfig if a hot reload is desired.","Investigate why the core died before the reload — check core logs for config errors, port conflicts, or permission problems.","Accept the fallback: the warning indicates restartCore() was used, which is slower but equivalent; no action strictly required."],"exampleFix":"// before\nawait mihomoHotReloadConfig()\n// after\nimport { hasCoreProcess } from './core/process'\nif (!hasCoreProcess()) {\n  await startCore() // ensure core runs so hot reload path is taken\n}\nawait mihomoHotReloadConfig()","handlingStrategy":"fallback","validationCode":"import { hasCoreProcess } from '@/main/core/process'\nif (!hasCoreProcess()) {\n  await startCore() // or resolve coreStartPromise before hot reload\n}","typeGuard":null,"tryCatchPattern":"try {\n  await mihomoHotReloadConfig()\n} catch (e) {\n  logger.error('hot reload failed, falling back to full restart', e)\n  await restartCore()\n}","preventionTips":["Gate config-reload calls behind a core-running check (hasCoreProcess or a coreStarted promise).","Subscribe to core process exit events to update UI state so reloads aren't fired against a dead core.","Treat this warning as informational — the restart fallback preserves correctness."],"tags":["mihomo","core-process","hot-reload","fallback"],"backgroundTag":"core-process-not-running","analyzedSha":"911e090537acdf7c50bee1c3aebecc2ef119a8b5","analyzedAt":"2026-08-30T13:00:49.174Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}