DTK0025: Cannot Change Command ID
Package:
@vitejs/devtools
Message
Cannot change the id of a command. Use register() to add new commands.
Cause
The update method on a DevToolsCommandHandle was called with a patch object that includes an id property. Command IDs are immutable after registration -- they serve as the stable key in the commands map and cannot be changed via update.
Example
ts
export default defineDevToolsPlugin({
name: 'my-plugin',
setup(context) {
const handle = context.commands.register({
id: 'my-plugin:reload',
label: 'Reload',
handler: () => { /* ... */ },
})
// Attempting to change the id throws DTK0025
handle.update({ id: 'my-plugin:new-id', label: 'New Label' })
},
})Fix
If you need a command with a different id, unregister the existing command and register a new one.
ts
handle.unregister()
const newHandle = context.commands.register({
id: 'my-plugin:new-id',
label: 'New Label',
handler: () => { /* ... */ },
})To update other properties of a command without changing its id, omit the id field from the patch:
ts
handle.update({ label: 'Updated Label' })Source
packages/core/src/node/host-commands.ts