mihomo-party-org/clash-party · info
Core is not running, restarting core before config patch
Error message
Core is not running, restarting core before config patch
What it means
patchMihomoConfig patches the running core's configuration via its REST API. If there is no core process and the app is ready (i.e. this is not a pre-ready migration), the patch would fail, so the function logs this warning and restarts the core first. This makes config patches double as a recovery path after a failed startup.
Source
Thrown at src/main/core/mihomoApi.ts:217
)
return axiosIns
}
export async function mihomoVersion(): Promise<IMihomoVersion> {
const instance = await getAxios()
return await instance.get('/version')
}
export const patchMihomoConfig = async (patch: Partial<IMihomoConfig>): Promise<void> => {
const patchConfig = async (): Promise<void> => {
const instance = await getAxios()
await instance.patch('/configs', patch)
}
// Configuration patches can also be the first recovery action after startup
// failed. Do not start the core during pre-ready migrations.
if (!hasCoreProcess() && app.isReady()) {
mihomoApiLogger.warn('Core is not running, restarting core before config patch')
await restartCore()
}
try {
await patchConfig()
} catch (error) {
if (hasCoreProcess() || !app.isReady()) throw error
mihomoApiLogger.warn('Core exited before config patch completed, restarting core', error)
await restartCore()
await patchConfig()
}
}
export const mihomoCloseConnection = async (id: string): Promise<void> => {
const instance = await getAxios()
return await instance.delete(`/connections/${encodeURIComponent(id)}`)
}View on GitHub (pinned to 911e090537)
Solutions
- No action needed — the function restarts the core automatically before patching; watch logs to confirm restartCore succeeds.
- If restarts keep happening, fix why the core dies: inspect the core log for config errors and correct the profile/config.
- Verify the core binary runs (correct version, permissions, ports not occupied by another process).
- After the automatic restart, confirm the patch was applied by checking the core's /configs or app UI state.
Example fix
// before
if (!hasCoreProcess() && app.isReady()) {
mihomoApiLogger.warn('Core is not running, restarting core before config patch')
await restartCore()
}
await patchConfig()
// after
if (!hasCoreProcess() && app.isReady()) {
mihomoApiLogger.warn('Core is not running, restarting core before config patch')
await restartCore()
}
try {
await patchConfig()
} catch (error) {
mihomoApiLogger.error('Config patch failed after core restart', error)
throw error
} Defensive patterns
Strategy: try-catch
Validate before calling
// Caller-side check before patching:
import { hasCoreProcess } from './core/manager'
if (!hasCoreProcess()) {
console.warn('Core not running — the next patch will trigger a core restart')
} Try / catch
try {
await patchMihomoConfig(patch)
} catch (e) {
// patchMihomoConfig already restarts the core; failure here means restart or API call failed
mihomoApiLogger.error('Config patch failed even after core restart — inspect core logs', e)
throw e
} Prevention
- Fix recurring core startup failures (invalid profile config, occupied ports) so the core stays up.
- Inspect core logs after each automatic restart to confirm it became healthy.
- Ensure the core binary is installed, executable, and up to date.
- Apply config changes through the app UI so the restart-before-patch logic runs as designed.
When it happens
Trigger: A config change (e.g. mode switch, port change, rule update) is applied while the core is not running — typically right after a failed startup or a manual core stop; app.isReady() is true so the patch is treated as a user action needing a live core.
Common situations: User toggles settings after the core crashed at startup; core was stopped by the watchdog after repeated crashes; core failed to start due to a bad config and the user edits settings, triggering a patch; switching profiles while the core is down.
Related errors
- Subscription failed: Profile is not a valid YAML
- Subscription failed: Profile missing proxies or providers
- Empty URL
- Core process watchdog exited unexpectedly, code: ${code}, si
- Core PID ${proc.pid ?? 'unknown'} did not exit after SIGINT;
AI-assisted analysis of mihomo-party-org/clash-party@911e090537 (2026-08-30).
Data as JSON: /api/errors/93131d5f4b68ef46.
Report an issue: GitHub.