DTK0016: Cannot Change Dock ID
Package:
@vitejs/devtools
Message
Cannot change the id of a dock. Use register() to add new docks.
Cause
This error is thrown by the update() method returned from DevToolsDockHost.register() when you attempt to change the id field of a registered dock. Dock ids are immutable after registration because they serve as the primary key in the dock host's internal Map. Changing an id would break the association between the entry and its key.
The check specifically fires when patch.id is defined and differs from the original view.id.
Example
ts
// In a plugin's devtools.setup() hook
export default function myPlugin(): Plugin {
return {
name: 'my-plugin',
devtools: {
setup(context) {
const dock = context.docks.register({
id: 'my-plugin:overview',
type: 'iframe',
title: 'Overview',
icon: 'ph:eye-duotone',
category: 'analysis',
src: '/.my-plugin/',
})
// Attempting to change the id throws DTK0016
dock.update({ id: 'my-plugin:dashboard' })
},
},
}
}Fix
Dock ids cannot be changed after registration. If you need a dock with a different id, register a new dock instead:
ts
const dock = context.docks.register({
id: 'my-plugin:overview',
type: 'iframe',
title: 'Overview',
icon: 'ph:eye-duotone',
category: 'analysis',
src: '/.my-plugin/',
})
// Update non-id properties -- this works fine
dock.update({ title: 'Dashboard', icon: 'ph:chart-bar-duotone' })
// For a new id, register a separate dock
context.docks.register({
id: 'my-plugin:dashboard',
type: 'iframe',
title: 'Dashboard',
icon: 'ph:chart-bar-duotone',
category: 'analysis',
src: '/.my-plugin/dashboard',
})Source
packages/core/src/node/host-docks.ts