mihomo-party-org/clash-party · warning

Core startup was cancelled because the application is shutti

Error message

Core startup was cancelled because the application is shutting down

What it means

This error is thrown by ensureCoreOperationAllowed() in src/main/core/manager.ts:143 when coreOperationPhase === 'shutting-down'. It means a core operation (startCore, stopCore, restartCore, restartCoreAfterUnexpectedExit) was requested while the application is in the middle of shutting down, so the library cancels it to avoid starting or mutating the core during teardown.

Source

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

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(
    () => undefined,
    () => undefined
  )
  return current
}

View on GitHub (pinned to 911e090537)

Solutions

  1. Listen for the app's shutdown/before-quit signal and stop issuing core operations at that point
  2. Guard core calls behind a check that the app is not shutting down (e.g. an isShuttingDown flag exposed by the app)
  3. Treat this error as benign and swallow it in quit paths — the core is being torn down intentionally

Example fix

// before
await restartCore()
// after
if (!app.isShuttingDown) { await restartCore() } else { log.info('skip restart during shutdown') }
Defensive patterns

Strategy: try-catch

Validate before calling

if (coreOperationPhase === 'shutting-down' || app.isShuttingDown) {
  return // skip core operation entirely
}

Try / catch

try {
  await restartCore()
} catch (err) {
  if (err.message.includes('application is shutting down')) {
    log.info('Core restart skipped: app shutting down')
    return
  }
  throw err
}

Prevention

When it happens

Trigger: Invoking startCore(), stopCore(), restartCore(), or restartCoreAfterUnexpectedExit() after app shutdown began and set coreOperationPhase to 'shutting-down' (via beginShutdown / quit flow), including queued operations that resolve after shutdown started.

Common situations: A renderer or IPC handler triggering a core restart while the user quits the app; a queued restart promise resolving during app close; OS shutdown or window close firing while a core operation was pending.

Related errors


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