stablyai/orca · error · Error

Choose another Active Server in Advanced before removing thi

Error message

Choose another Active Server in Advanced before removing this server.

What it means

Thrown by the runtimeEnvironments:remove handler when the environment being removed is currently selected as the Active Server (store.getSettings().activeRuntimeEnvironmentId === environment.id). Removing it would leave the app pointed at a non-existent server, so the user must first switch the Active Server preference to another environment (or to null) in Advanced settings.

Source

Thrown at src/main/ipc/runtime-environment-connectivity-handlers.ts:88

  ipcMain.handle(
    'runtimeEnvironments:verifyAndAddFromPairingCode',
    async (_event, args: { name: string; pairingCode: string; allowLoopback?: boolean }) => {
      const result = await verifyAndAddRuntimeEnvironmentFromPairingCode(getUserDataPath(), args)
      if (result.ok) {
        manuallyDisconnectedEnvironmentIds.delete(result.environment.id)
      }
      return result
    }
  )
  ipcMain.handle('runtimeEnvironments:resolve', (_event, args: { selector: string }) =>
    redactRuntimeEnvironment(resolveEnvironment(getUserDataPath(), args.selector))
  )
  ipcMain.handle(
    'runtimeEnvironments:remove',
    (_event, args: { selector: string }): { removed: PublicKnownRuntimeEnvironment } => {
      const environment = resolveEnvironment(getUserDataPath(), args.selector)
      if (store.getSettings().activeRuntimeEnvironmentId === environment.id) {
        throw new Error('Choose another Active Server in Advanced before removing this server.')
      }
      const removed = removeEnvironment(getUserDataPath(), args.selector)
      manuallyDisconnectedEnvironmentIds.delete(removed.id)
      invalidateTransport(removed.id)
      closeLegacySelectorTransport(args.selector, removed.id)
      return { removed: redactRuntimeEnvironment(removed) }
    }
  )
  ipcMain.handle(
    'runtimeEnvironments:disconnect',
    (_event, args: { selector: string }): { disconnected: PublicKnownRuntimeEnvironment } => {
      const environment = resolveEnvironment(getUserDataPath(), args.selector)
      manuallyDisconnectedEnvironmentIds.add(environment.id)
      invalidateTransport(environment.id)
      closeLegacySelectorTransport(args.selector, environment.id)
      return { disconnected: redactRuntimeEnvironment(environment) }
    }
  )

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Before calling remove, set the Active Server preference to another environment via settings:set-active-runtime-environment-preference (or to null).
  2. In the UI, disable Remove for the active server, or auto-offer to switch active first.
  3. After removal, confirm the new active server connects before continuing.
  4. If only one server exists, set the preference to null before removing it.

Example fix

// before
await ipc.invoke('runtimeEnvironments:remove', { selector })

// after
if (activeId === envToRemove.id) {
  await ipc.invoke('settings:set-active-runtime-environment-preference', {
    environmentId: fallbackEnvId ?? null,
  })
}
await ipc.invoke('runtimeEnvironments:remove', { selector })
Defensive patterns

Strategy: validation

Validate before calling

const settings = await ipc.invoke('settings:get')
if (settings.activeRuntimeEnvironmentId === envToRemove.id) {
  await ipc.invoke('settings:set-active-runtime-environment-preference', {
    environmentId: fallbackId ?? null,
  })
}
await ipc.invoke('runtimeEnvironments:remove', { selector })

Type guard

function isActiveServer(envId: string, activeId: string | null | undefined): boolean {
  return activeId === envId
}

Try / catch

try {
  await ipc.invoke('runtimeEnvironments:remove', { selector })
} catch (e) {
  if (/Active Server/i.test((e as Error).message)) {
    promptSwitchActiveServer(envToRemove)
  } else throw e
}

Prevention

When it happens

Trigger: User opens server management, selects the currently-active server, and clicks Remove without first changing the Active Server dropdown. The guard blocks the removal to prevent an invalid active preference.

Common situations: Cleaning up old/test servers while one of them is still the active target; reorganizing servers after a migration; forgetting that the active server is the one being deleted.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/16d71f0ac191a869. Report an issue: GitHub.