{"record":{"id":"092b284731a65112","repo":"siyuan-note/siyuan","slug":"enablesiyuanmodule-v","errorCode":null,"errorMessage":"EnableSiyuanModule: %v","messagePattern":"EnableSiyuanModule: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/plugin.go","lineNumber":205,"sourceCode":"\tp.worker.Start(p.runtime)\n\n\tp.runtime.Run(func(rt *goja.Runtime) {\n\t\tdefer func() {\n\t\t\tif r := recover(); r != nil {\n\t\t\t\terr = fmt.Errorf(\"goja panic during event loop run: %v\", r)\n\t\t\t}\n\t\t}()\n\n\t\t// Use JSON struct tags for field name mapping, with fallback to original names if \"json\" tag is absent.\n\t\trt.SetFieldNameMapper(goja.TagFieldNameMapper(\"json\", true))\n\n\t\tif enableErr := EnableExtendModules(p, rt); enableErr != nil {\n\t\t\terr = fmt.Errorf(\"EnableExtendModules: %v\", enableErr)\n\t\t\treturn\n\t\t}\n\n\t\tif enableErr := EnableSiyuanModule(p, rt); enableErr != nil {\n\t\t\terr = fmt.Errorf(\"EnableSiyuanModule: %v\", enableErr)\n\t\t\treturn\n\t\t}\n\n\t\tif _, runErr := rt.RunScript(p.file, p.Kernel.JS); runErr != nil {\n\t\t\terr = fmt.Errorf(\"RunScript: %v\", runErr)\n\t\t\treturn\n\t\t}\n\t})\n\tp.runtime.Start()\n\treturn\n}\n\n// Eval evaluates JavaScript code in the plugin's goja runtime, returning the result or error.\nfunc (p *KernelPlugin) Eval(rt *goja.Runtime, code string) (goja.Value, error) {\n\treturn rt.RunScript(p.file, code)\n}\n\n// close interrupts the goja runtime and clears the pointer.","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/plugin/plugin.go#L187-L223","documentation":"After extend modules, `EnableSiyuanModule` installs the `siyuan` namespace (storage, events, etc.) into the plugin runtime. An error there is wrapped as `EnableSiyuanModule: %v` and aborts plugin startup. The plugin will end in PluginStateError and its capabilities are cleared.","triggerScenarios":"EnableSiyuanModule returning an error while registering the siyuan object (e.g. assertion failure setting a frozen property on the runtime), during InitRuntime before the plugin's kernel.js is executed.","commonSituations":"Kernel upgrade inconsistencies, corrupted runtime state from a previous failed start, or resource exhaustion inside goja.","solutions":["Read the wrapped inner error to identify which siyuan sub-module (storage, events, etc.) failed","Disable and re-enable the plugin for a fresh runtime","Restart the SiYuan kernel if multiple plugins show the same failure","Update SiYuan; report with the full error if persistent"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := plugin.Start(); err != nil && strings.Contains(err.Error(), \"EnableSiyuanModule\") { // mark plugin errored, surface to UI }","preventionTips":["Re-enable the plugin (fresh runtime) after any failed start","Restart the kernel if several plugins fail identically","Keep SiYuan and plugins on compatible versions","Capture the wrapped inner error for bug reports"],"tags":["plugin-lifecycle","goja","module-registration"],"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"}