{"record":{"id":"faed84e0c4f08e4b","repo":"siyuan-note/siyuan","slug":"injectserver-v","errorCode":null,"errorMessage":"injectServer: %v","messagePattern":"injectServer: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/api_server.go","lineNumber":30,"sourceCode":"// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\npackage plugin\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/dop251/goja\"\n\t\"github.com/samber/lo\"\n)\n\n// injectServer adds siyuan.server to the goja context.\nfunc injectServer(p *KernelPlugin, rt *goja.Runtime, siyuan *goja.Object) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"injectServer: %v\", r)\n\t\t}\n\t}()\n\n\thttp := rt.NewObject()\n\tws := rt.NewObject()\n\tes := rt.NewObject()\n\n\tlo.Must0(http.Set(\"handler\", goja.Null()))\n\tlo.Must0(ws.Set(\"handler\", goja.Null()))\n\tlo.Must0(es.Set(\"handler\", goja.Null()))\n\n\tlo.Must0(ObjectSeal(rt, http))\n\tlo.Must0(ObjectSeal(rt, ws))\n\tlo.Must0(ObjectSeal(rt, es))\n\n\tprivate := rt.NewObject()\n\n\tlo.Must0(private.Set(string(RequestTypeHTTP), http))","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/plugin/api_server.go#L12-L48","documentation":"injectServer installs the siyuan.server object (http/ws/es handler slots) into a kernel plugin's goja runtime. A panic inside the injection (e.g. lo.Must0 failing because a property could not be set on a sealed object, or goja runtime misuse) is recovered and wrapped as \"injectServer: %v\". The plugin load then fails with this error. It indicates a kernel-side injection failure, not a problem in the plugin's JavaScript code.","triggerScenarios":"A panic during injectServer: lo.Must0 sees a non-nil error from Object.Set / ObjectSeal / ObjectFreeze / siyuan.Set (e.g. the target object is already sealed or the runtime is in a broken state), or any unexpected panic inside the function while loading the plugin.","commonSituations":"Kernel/plugin host bug or a corrupted plugin runtime state during plugin load; typically hit during SiYuan startup or when enabling a kernel plugin after an abnormal shutdown; rarely caused by user configuration.","solutions":["Check the full log line for the wrapped panic message to identify the actual panic cause","Restart SiYuan and re-enable the plugin; corrupted goja runtime state is transient","Update SiYuan to the latest version; this is an internal injection path likely fixed upstream","If reproducible, disable the offending plugin and file an issue with the stack trace"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Kernel-side Go code loading the plugin\nif err := injectServer(p, rt, siyuan); err != nil {\n    return fmt.Errorf(\"plugin %s load failed: %w\", p.Name, err)\n}","preventionTips":["Keep the goja runtime freshly created per plugin load; do not reuse broken runtimes","Check SiYuan release notes for plugin subsystem fixes before reporting","Capture the wrapped panic message from logs to attach to bug reports"],"tags":["goja","plugin","kernel","panic","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}