Skip to content

DTK0005: Function Not in Dump Store

Package: @vitejs/devtools-rpc

Message

Function "{name}" not found in dump store

Cause

This error is thrown by createClientFromDump() when you call a function on the dump client that was not included in the definitions passed to dumpFunctions(). The dump store only contains entries for functions that were part of the original dump collection, and the client rejects calls to unknown functions.

Example

ts
import { defineRpcFunction } from '@vitejs/devtools-kit'
import { createClientFromDump, dumpFunctions } from '@vitejs/devtools-rpc'

const getVersion = defineRpcFunction({
  name: 'my-plugin:get-version',
  type: 'static',
  handler: () => '1.0.0',
})

// Only getVersion is dumped
const store = await dumpFunctions([getVersion])
const client = createClientFromDump(store)

// Throws DTK0005 because 'my-plugin:get-config' is not in the store
await client['my-plugin:get-config']()

Fix

Include the function in the definitions array passed to dumpFunctions():

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

// Include all needed functions in the dump
const store = await dumpFunctions([getVersion, getConfig])
const client = createClientFromDump(store)

// Now both functions work
await client['my-plugin:get-version']()
await client['my-plugin:get-config']()

Source

packages/rpc/src/dumps.ts

Released under the MIT License.