Skip to content

DTK0015: Dock Already Registered

Package: @vitejs/devtools

Message

Dock with id "{id}" is already registered

Cause

This error is thrown by DevToolsDockHost.register() when you attempt to register a dock entry with an id that is already in use by another dock. The dock host maintains a Map of registered views keyed by id, and duplicate registrations are rejected by default to prevent accidental overwrites.

This commonly happens when:

  • Two plugins register docks with the same id.
  • A plugin's devtools.setup() hook runs more than once without cleanup.
  • A hard-coded id collides with another plugin's dock.

Example

ts
// In a plugin's devtools.setup() hook
export default function myPlugin(): Plugin {
  return {
    name: 'my-plugin',
    devtools: {
      setup(context) {
        context.docks.register({
          id: 'my-plugin:overview',
          type: 'iframe',
          title: 'Overview',
          icon: 'ph:eye-duotone',
          category: 'analysis',
          src: '/.my-plugin/',
        })

        // Registering the same id again throws DTK0015
        context.docks.register({
          id: 'my-plugin:overview',
          type: 'iframe',
          title: 'Overview v2',
          icon: 'ph:eye-duotone',
          category: 'analysis',
          src: '/.my-plugin/v2',
        })
      },
    },
  }
}

Fix

Use a unique id for each dock. If you intentionally need to replace an existing registration, pass force: true as the second argument:

ts
// Use the force parameter to overwrite
context.docks.register({
  id: 'my-plugin:overview',
  type: 'iframe',
  title: 'Overview v2',
  icon: 'ph:eye-duotone',
  category: 'analysis',
  src: '/.my-plugin/v2',
}, true)

If you need to update properties of an already-registered dock without replacing it, use the update function returned from the initial register() call:

ts
const dock = context.docks.register({
  id: 'my-plugin:overview',
  type: 'iframe',
  title: 'Overview',
  icon: 'ph:eye-duotone',
  category: 'analysis',
  src: '/.my-plugin/',
})

// Update properties later
dock.update({ title: 'Overview v2' })

Source

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

Released under the MIT License.