Skip to content

DTK0012: RPC General Error

Package: @vitejs/devtools

Message

RPC error on executing rpc

Cause

This error is logged when a general RPC error occurs outside of a specific function invocation. It is triggered by the onGeneralError hook in the createRpcServer configuration inside createWsServer().

Unlike DTK0011 which is scoped to a named function, this diagnostic covers errors in the RPC transport layer itself -- for example, message serialization failures, WebSocket protocol errors, or issues in the RPC resolver pipeline. The original error is attached as cause.

Example

General RPC errors typically arise from infrastructure-level issues rather than user code. For instance, if a function returns a value that cannot be serialized over the WebSocket connection:

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

const myFunction = defineRpcFunction({
  name: 'my-plugin:get-stream',
  async handler() {
    // Returning a non-serializable value may cause a general RPC error
    return new ReadableStream()
  },
})

Fix

  1. Check the cause attached to the diagnostic for the underlying error details.
  2. Ensure all RPC function return values are JSON-serializable.
  3. If the error appears to be a WebSocket connectivity issue, verify that the DevTools server and client are properly connected.
  4. If the error persists and appears to be a bug in the RPC layer, report it to the Vite DevTools repository.

Source

packages/core/src/node/ws.ts

Released under the MIT License.