siyuan-note/siyuan · error · JsonRpcError
${data.error.message}
Error message
${data.error.message} What it means
KernelPlugin.#rpcCall() throws a JsonRpcError wrapping data.error whenever a JSON-RPC 2.0 response from the kernel-side plugin contains an 'error' object. JsonRpcError's message is data.error.message, its code is data.error.code, and data is data.error.data — i.e. any kernel-plugin RPC method that fails (method not found, params invalid, plugin threw) surfaces here.
Source
Thrown at app/src/plugin/kernel.ts:191
return data;
}
await new Promise(resolve => window.setTimeout(resolve, KERNEL_PLUGIN_START_RETRY_INTERVAL));
}
}
async #initState() {
const response = await fetchSyncPost("/api/plugin/getLoadedPlugin", { name: this.#name });
if (this.state.code === -1 && response.data?.stateCode != null) {
this.state.code = response.data.stateCode;
}
}
async #rpcCall(method: TJsonRpcMethod, ...params: TJsonRpcMethodParams): Promise<any> {
const id = this.#generateId();
const data = await this.#fetchRpc(JSON.stringify({ jsonrpc: "2.0", id, method, params }));
if (data.error) {
throw new JsonRpcError(data.error);
}
return data.result;
}
#rpcNotify(method: TJsonRpcMethod, ...params: TJsonRpcMethodParams): void {
this.#fetchRpc(JSON.stringify({ jsonrpc: "2.0", method, params })).catch((error) => {
console.error(`Failed to send JSON-RPC notification for method ${method}:`, error);
});
}
async #rpcBatchCall(...calls: IKernelPluginRpcCall[]): Promise<IKernelPluginRpcError | (IKernelPluginRpcResultResponse | IKernelPluginRpcErrorResponse)[]> {
const requests = calls.map(call => {
const request: IKernelPluginRpcRequest = { jsonrpc: "2.0", method: call.method };
if (call.params != null) {
request.params = call.params;
}
if (!call.notification) {
request.id = call.id ?? this.#generateId();View on GitHub (pinned to 251596fc0d)
Solutions
- Catch JsonRpcError specifically, read err.code (JSON-RPC standard: -32601 method not found, -32602 invalid params, -32000/-32001 plugin state errors) and err.data for context.
- Verify the method name and params schema against the kernel plugin's registered RPC surface.
- For -32001/-32002 (plugin not started), wait for the plugin init event or retry within KERNEL_PLUGIN_START_RETRY_COUNT.
- Ensure the kernel plugin is enabled and loaded (check /api/plugin/getLoadedPlugin).
Example fix
// before
const r = await kernelPlugin.rpc('doThing', arg);
// after
import {JsonRpcError} from './plugin/kernel';
try { const r = await kernelPlugin.rpc('doThing', arg); }
catch (e) {
if (e instanceof JsonRpcError && (e.code === -32001 || e.code === -32002)) {
showMessage('Plugin still starting, please retry'); return;
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
const loaded = (await fetchSyncPost('/api/plugin/getLoadedPlugin', {name}))?.data;
if (!loaded || loaded.stateCode !== 0) throw new Error('Kernel plugin not loaded'); Type guard
function isJsonRpcError(e: unknown): e is JsonRpcError {
return e instanceof Error && typeof (e as any).code === 'number';
} Try / catch
try { return await kernelPlugin.rpc(method, ...params); }
catch (e) {
if (e instanceof JsonRpcError && (e.code === -32001 || e.code === -32002)) { /* retry once after init */ }
throw e;
} Prevention
- Always await kernel plugin init before issuing RPC calls.
- Match the method name and params schema to the kernel plugin's exported surface.
- Catch JsonRpcError and branch on err.code for targeted recovery.
- Verify the plugin is enabled via /api/plugin/getLoadedPlugin before calling.
When it happens
Trigger: Calling a plugin-exported RPC method that the kernel does not know (method not registered), passing malformed params (schema validation failure), the kernel plugin returning an error from its handler, or the plugin process being down so the kernel reports -32001/-32002.
Common situations: Plugin version mismatch (frontend calls a method the installed kernel plugin does not export); params shape changed across versions; kernel plugin crashed and its load is being retried; permission denied invoking a method.
Related errors
- Failed to save agent session
- Failed to remove agent session
- Failed to update agent session permission
- Agent capability name and description are required
- stopped after 10 redirects
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/e0dbff75e11263de.
Report an issue: GitHub.