siyuan-note/siyuan · error
failed to convert request value to object
Error message
failed to convert request value to object
What it means
In handleWebSocketRequest, the Go Request is converted to a JS value with requestGoToJs; if that succeeds but jsRequest.ToObject(rt) still returns nil, the kernel cannot obtain a JS object handle for the request and returns this internal conversion error. It signals that the plugin runtime failed to materialize the request as an object, so the WS handler cannot be invoked. This is a defensive internal invariant check rather than a caller-input error.
Solutions
- Retry the plugin request after confirming the plugin is enabled and the runtime is alive (check kernel logs for '[plugin:<name>]' errors)
- Disable and re-enable (or reinstall) the plugin to reset its JS worker
- Update the plugin to the latest version matching your SiYuan kernel version
- If reproducible at startup, report the kernel log snippet to the plugin author / SiYuan issue tracker
Defensive patterns
Strategy: retry
Validate before calling
if (!plugin || plugin.status !== "enabled") { await reloadPlugin(plugin); } Try / catch
try { await openWs(request); } catch (e) { if (String(e).includes("failed to convert request value to object")) { await restartPluginWorker(); } throw e; } Prevention
- Keep plugins updated to match the running kernel version
- Avoid disabling/reloading plugins while requests are in flight
- Watch kernel logs for '[plugin:<name>]' runtime errors at startup
- Re-enable the plugin to reset the goja worker when conversion errors recur
When it happens
Trigger: requestGoToJs returns a non-nil goja.Value that is not object-coercible (e.g. null/undefined-like), so ToObject yields nil; runtime in an invalid state (interrupted/closed worker) during request conversion.
Common situations: Plugin runtime shutting down mid-request; goja runtime corruption or interruption; upgrading SiYuan with an old plugin binary that changed the Request serialization contract; extremely rare — mostly seen during shutdown races.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- invalid response format
- plugin WebSocket control frame exceeds 125 bytes
- undeclared plugin WebSocket frame
- WebSocket handshake contains a body
- WebSocket is not open
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/4a505e41021a4cdc.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/plugin/plugin.go:1057
var bufferedAmount atomic.Int64
readyState.Store(int64(WebSocketReadyStateConnecting))
runErr := p.worker.Run(func(rt *goja.Runtime) (_ any, err error) {
handler, handlerObj, getHandlerErr := getRequestHandler(rt, scope, RequestTypeWS)
if getHandlerErr != nil {
err = getHandlerErr
return
}
jsRequest, convertErr := requestGoToJs(p, rt, request)
if convertErr != nil {
err = convertErr
return
}
jsRequestObj := jsRequest.ToObject(rt)
if jsRequestObj == nil {
err = fmt.Errorf("failed to convert request value to object")
return
}
port := rt.NewObject()
invokePortHook := func(_ *goja.Runtime, name string, args ...goja.Value) {
hook := port.Get(name)
if fn, ok := goja.AssertFunction(hook); ok {
if _, callErr := fn(port, args...); callErr != nil {
logging.LogErrorf("[plugin:%s] ws server port hook %q: %v", p.Name, name, callErr)
}
}
}
setProtocol := func(rt *goja.Runtime, protocol string) {
port.Set("protocol", rt.ToValue(protocol))
}
View on GitHub (pinned to 9f775e8a12)