Molunerfinn/PicGo · error

Toggle plugin failed

Error message

Toggle plugin failed

What it means

setPluginEnabled throws when the ENABLE_PLUGIN/DISABLE_PLUGIN RPC via pluginsAdapter.togglePluginEnabled returns success:false, using result.error or the fallback 'Toggle plugin failed'. The surrounding try/catch resets the mutating flag and the toast confirms only on success.

Source

Thrown at src/renderer/store/plugins/actions.ts:204

        throw new Error(result.errMsg || result.body || 'Install plugin failed')
      }

      await appActions.hydrateAppState()
      const installedPlugins = await pluginsAdapter.getInstalledPlugins()
      pluginStoreActions.setInstalledPlugins(installedPlugins.map(mapInstalledPluginItem))
      toast.success(i18n.t('PLUGIN_INSTALL_SUCCEED'))
    } finally {
      pluginStoreActions.setMutating(fullName, false)
    }
  },
  async setPluginEnabled (fullName: string, enabled: boolean) {
    pluginStoreActions.setMutating(fullName, true)

    try {
      const result = await pluginsAdapter.togglePluginEnabled(fullName, enabled)

      if (!result.success) {
        throw new Error(result.error || 'Toggle plugin failed')
      }

      await appActions.hydrateAppState()
      const installedPlugins = await pluginsAdapter.getInstalledPlugins()
      pluginStoreActions.setInstalledPlugins(installedPlugins.map(mapInstalledPluginItem))
      toast.success(i18n.t(enabled ? 'ENABLE_PLUGIN' : 'DISABLE_PLUGIN'))
    } finally {
      pluginStoreActions.setMutating(fullName, false)
    }
  },
  async updatePlugin (fullName: string) {
    pluginStoreActions.setMutating(fullName, true)

    try {
      const result = await pluginsAdapter.updatePlugin(fullName)
      if (!result.success) {
        throw new Error(result.error || 'Update plugin failed')
      }

View on GitHub (pinned to 07ec7068a5)

Solutions

  1. Check result.error in the thrown message for the handler's specific failure.
  2. Refresh the installed plugin list (pluginsAdapter.getInstalledPlugins) to ensure the fullName still exists.
  3. Reinstall the plugin if it was removed or corrupted on disk, then retry the toggle.
  4. Avoid concurrent toggles on the same plugin; wait for the mutating flag to clear.

Example fix

// before
const result = await pluginsAdapter.togglePluginEnabled(fullName, enabled)
if (!result.success) {
  throw new Error(result.error || 'Toggle plugin failed')
}
// after
const installed = await pluginsAdapter.getInstalledPlugins()
if (!installed.some(p => p.fullName === fullName)) {
  toast.error(i18n.t('PLUGIN_NOT_FOUND'))
  return
}
const result = await pluginsAdapter.togglePluginEnabled(fullName, enabled)
if (!result.success) {
  throw new Error(result.error || i18n.t('PLUGIN_TOGGLE_FAILED'))
}
Defensive patterns

Strategy: validation

Validate before calling

const installed = useAppStore.getState().pluginsInstalled
if (!installed.some(p => p.fullName === fullName)) {
  toast.error(i18n.t('PLUGIN_NOT_FOUND'))
  return
}
if (installed.find(p => p.fullName === fullName)?.enabled === enabled) {
  return // already in the desired state, skip the RPC
}

Type guard

function isToggleSuccess(r: { success: boolean, error?: string }): r is { success: true } {
  return r.success === true
}

Try / catch

try {
  await pluginStoreActions.setPluginEnabled(fullName, enabled)
} catch (e) {
  toast.error(e instanceof Error ? e.message : i18n.t('PLUGIN_TOGGLE_FAILED'))
  pluginStoreActions.setMutating(fullName, false)
}

Prevention

When it happens

Trigger: The main-process enable/disable handler fails: plugin not actually installed (removed on disk after list was cached), plugin's module fails to load/unload, internal handler error, or unknown fullName passed in.

Common situations: Toggling a plugin whose node_modules entry was deleted externally; stale UI list after manual filesystem changes; plugin with a broken main entry that cannot be enabled; race where two toggles run for the same plugin.

Related errors


AI-assisted analysis of Molunerfinn/PicGo@07ec7068a5 (2026-08-30). Data as JSON: /api/errors/f4dcac6b9619b0e8. Report an issue: GitHub.