{"record":{"id":"4a505e41021a4cdc","repo":"siyuan-note/siyuan","slug":"failed-to-convert-request-value-to-object","errorCode":null,"errorMessage":"failed to convert request value to object","messagePattern":"failed to convert request value to object","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/plugin.go","lineNumber":1057,"sourceCode":"\tvar bufferedAmount atomic.Int64\n\treadyState.Store(int64(WebSocketReadyStateConnecting))\n\n\trunErr := p.worker.Run(func(rt *goja.Runtime) (_ any, err error) {\n\t\thandler, handlerObj, getHandlerErr := getRequestHandler(rt, scope, RequestTypeWS)\n\t\tif getHandlerErr != nil {\n\t\t\terr = getHandlerErr\n\t\t\treturn\n\t\t}\n\n\t\tjsRequest, convertErr := requestGoToJs(p, rt, request)\n\t\tif convertErr != nil {\n\t\t\terr = convertErr\n\t\t\treturn\n\t\t}\n\n\t\tjsRequestObj := jsRequest.ToObject(rt)\n\t\tif jsRequestObj == nil {\n\t\t\terr = fmt.Errorf(\"failed to convert request value to object\")\n\t\t\treturn\n\t\t}\n\n\t\tport := rt.NewObject()\n\n\t\tinvokePortHook := func(_ *goja.Runtime, name string, args ...goja.Value) {\n\t\t\thook := port.Get(name)\n\t\t\tif fn, ok := goja.AssertFunction(hook); ok {\n\t\t\t\tif _, callErr := fn(port, args...); callErr != nil {\n\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] ws server port hook %q: %v\", p.Name, name, callErr)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsetProtocol := func(rt *goja.Runtime, protocol string) {\n\t\t\tport.Set(\"protocol\", rt.ToValue(protocol))\n\t\t}\n","sourceCodeStart":1039,"sourceCodeEnd":1075,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/plugin/plugin.go#L1039-L1075","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!plugin || plugin.status !== \"enabled\") { await reloadPlugin(plugin); }","typeGuard":null,"tryCatchPattern":"try { await openWs(request); } catch (e) { if (String(e).includes(\"failed to convert request value to object\")) { await restartPluginWorker(); } throw e; }","preventionTips":["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"],"tags":["goja","plugin-api","websocket","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}