neoclide/coc.nvim · error

Action "${method}" does not exist

Error message

Action "${method}" does not exist

What it means

cocAction() dispatches Vim-originated action requests by looking up the method name in the actions Map. If the name is not registered, it throws this error, meaning Vim called an action the plugin does not provide.

Source

Thrown at src/plugin.ts:287

    nvim.resumeNotification(false, true)
    void mcp.init(mcpStarted)
    const duration = typeof global.__starttime === 'number' ? Date.now() - global.__starttime : 0
    logger.info(`coc.nvim initialized with node: ${process.version} after`, duration)
    this.ready = true
    await events.fire('ready', [])
  }

  public get isReady(): boolean {
    return this.ready
  }

  public hasAction(method: string): boolean {
    return this.actions.has(method)
  }

  public async cocAction(method: string, ...args: any[]): Promise<any> {
    let fn = this.actions.get(method)
    if (!fn) throw new Error(`Action "${method}" does not exist`)
    return await Promise.resolve(fn.apply(null, args))
  }

  public getHandler(): Handler {
    return this.handler
  }

  public dispose(): void {
    disposeAll(this.disposables)
    extensions.dispose()
    listManager.dispose()
    workspace.dispose()
    window.dispose()
    sources.dispose()
    services.dispose()
    snippetManager.dispose()
    commandManager.dispose()
    completion.dispose()

View on GitHub (pinned to 50e974d969)

Solutions

  1. Verify the action name against current docs (:h coc-actions) and fix typos
  2. Ensure the extension providing the action is installed and activated before calling it
  3. Guard in Vim script with coc#client#has_action or check via try/catch around CocAction
  4. Update mappings/config that reference actions renamed or removed in newer coc.nvim versions

Example fix

" before
noremap <silent> gx :call CocAction('doAction2')<CR>
" after
noremap <silent> gx :call CocAction('doAction')<CR>
Defensive patterns

Strategy: try-catch

Validate before calling

" Vim script guard
if coc#client#has_action('myAction')
  call CocAction('myAction')
endif

Try / catch

try {
  await plugin.cocAction('myAction', arg)
} catch (e) {
  if (e.message.includes('does not exist')) {
    window.showErrorMessage(`Action not available: ${e.message}`)
  }
}

Prevention

When it happens

Trigger: Calling :call coc#client#request or CocAction('methodName') / CocActionAsync with a name never registered via addAction — including typos, actions from a disabled/unloaded extension, or actions removed in a coc.nvim version upgrade.

Common situations: Old vimrc/plugin configs calling renamed actions after upgrading coc.nvim; invoking an action provided only by an extension that failed to activate; typo'd action names in mappings like nmap <silent> gd :call CocAction('jumpDefinition2').

Related errors


AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31). Data as JSON: /api/errors/025e3c261d47d2a4. Report an issue: GitHub.