Skip to content

DTK0026: Command Not Registered

Package: @vitejs/devtools

Message

Command "{id}" is not registered

Cause

This error is thrown in two situations within the DevToolsCommandsHost:

  1. execute() -- Attempting to execute a command by id, but no command with that id is found in the commands map or as a child of any registered command.
  2. handle.update() -- Attempting to update a command via its handle, but the command was already unregistered.

Example

ts
export default defineDevToolsPlugin({
  name: 'my-plugin',
  setup(context) {
    // Executing a command that was never registered throws DTK0026
    await context.commands.execute('my-plugin:nonexistent')
  },
})
ts
// Or: updating after unregister
const handle = context.commands.register({
  id: 'my-plugin:reload',
  label: 'Reload',
  handler: () => { /* ... */ },
})

handle.unregister()

// This throws DTK0026 because the command no longer exists
handle.update({ label: 'Updated' })

Fix

Register the command before executing or updating it. If the command may not exist, check the commands map first.

ts
// Register the command
context.commands.register({
  id: 'my-plugin:reload',
  label: 'Reload',
  handler: () => { /* ... */ },
})

// Now it can be executed
await context.commands.execute('my-plugin:reload')

Source

packages/core/src/node/host-commands.ts

Released under the MIT License.