Skip to content

DTK0003: RPC Function Schema Not Found

Package: @vitejs/devtools-rpc

Message

RPC function "{name}" is not registered

Cause

This error is thrown by RpcFunctionsCollectorBase.getSchema() when you request the argument and return schemas for a function name that does not exist in the collector. The function must be registered before its schema can be queried.

Example

ts
// Throws DTK0003 because 'my-plugin:get-config' was never registered
const schema = collector.getSchema('my-plugin:get-config')

Fix

Ensure the function is registered before querying its schema. You can check whether a function exists first using has():

ts
import { defineRpcFunction } from '@vitejs/devtools-kit'

const getConfig = defineRpcFunction({
  name: 'my-plugin:get-config',
  type: 'query',
  handler: () => ({ debug: false }),
})

// Register first
collector.register(getConfig)

// Now getSchema works
const schema = collector.getSchema('my-plugin:get-config')

// Or guard with has()
if (collector.has('my-plugin:get-config')) {
  const schema = collector.getSchema('my-plugin:get-config')
}

Source

packages/rpc/src/collector.ts

Released under the MIT License.