mihomo-party-org/clash-party · warning

Core is still initializing

Error message

Core is still initializing

What it means

ensureCoreOperationAllowed gates core lifecycle operations (startCore, stopCore, restartCore, restartCoreAfterUnexpectedExit) against a module-level coreOperationPhase state machine. If the phase is 'initializing' (startup safety checks still running), it throws 'Core is still initializing' to prevent concurrent/lifecycle races.

Source

Thrown at src/main/core/manager.ts:137

}

export function hasCoreProcess(): boolean {
  return Boolean(child && !child.killed && child.exitCode === null && child.signalCode === null)
}

export function beginCoreInitialization(): void {
  coreOperationPhase = 'initializing'
}

export function completeCoreInitialization(canStart: boolean): void {
  if (coreOperationPhase !== 'shutting-down') {
    coreOperationPhase = canStart ? 'ready' : 'blocked'
  }
}

function ensureCoreOperationAllowed(): void {
  if (coreOperationPhase === 'initializing') {
    throw new Error('Core is still initializing')
  }
  if (coreOperationPhase === 'blocked') {
    throw new Error('Core startup is unavailable because startup safety checks did not pass')
  }
  if (coreOperationPhase === 'shutting-down') {
    throw new Error('Core startup was cancelled because the application is shutting down')
  }
}

function ensureNotShuttingDown(): void {
  if (coreOperationPhase === 'shutting-down') {
    throw new Error('Core startup was cancelled because the application is shutting down')
  }
}

function runCoreOperation<T>(operation: () => Promise<T>): Promise<T> {
  const current = coreOperationTail.then(operation, operation)
  coreOperationTail = current.then(

View on GitHub (pinned to 911e090537)

Solutions

  1. Wait for core initialization to complete before invoking core operations (listen for the app's ready/initialized signal).
  2. Retry the operation after a short delay if it must be issued around startup.
  3. Guard IPC handlers on the renderer side to disable core controls during the initializing phase.
  4. If initialization seems stuck, check startup safety check logs for why the phase never reaches 'ready'.

Example fix

// before
onAppReady(() => restartCore()) // may run during 'initializing'
// after
whenCoreInitialized(async () => {
  try { await restartCore() }
  catch (e) {
    if (e.message === 'Core is still initializing') await retryWithDelay(restartCore)
  }
})
Defensive patterns

Strategy: retry

Validate before calling

// on the renderer side, gate calls on app readiness
if (!coreReady) {
  await waitForCoreReadySignal() // e.g. IPC event 'core:ready'
}
await restartCore()

Try / catch

async function safeRestart() {
  try {
    await restartCore()
  } catch (e) {
    if (e.message === 'Core is still initializing') {
      await new Promise((r) => setTimeout(r, 1000))
      return safeRestart() // or use the core:ready event
    }
    throw e
  }
}

Prevention

When it happens

Trigger: Calling startCore/stopCore/restartCore (directly or via IPC) while the app is still in the 'initializing' phase — i.e. before startup safety checks complete and set the phase to 'ready' or 'blocked'.

Common situations: Renderer fires start/restart immediately on app launch before initialization finishes; automation scripts driving IPC faster than startup; a restart requested during the startup window after an unexpected core exit.

Related errors


AI-assisted analysis of mihomo-party-org/clash-party@911e090537 (2026-08-30). Data as JSON: /api/errors/491cfec164e3cf8d. Report an issue: GitHub.