{"record":{"id":"5f80bb8b51c4d48d","repo":"siyuan-note/siyuan","slug":"failed-to-enable-extend-modules-v","errorCode":null,"errorMessage":"failed to enable extend modules: %v","messagePattern":"failed to enable extend modules: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/sandbox.go","lineNumber":79,"sourceCode":"type FunctionResult[T any] struct {\n\tValue T\n\tError error\n}\n\ntype CallResult FunctionResult[goja.Value]\n\nfunc (r *CallResult) TaskResult() *TaskResult {\n\tif r.Error != nil {\n\t\treturn &TaskResult{err: r.Error}\n\t}\n\treturn &TaskResult{value: r.Value.Export()}\n}\n\n// EnableExtendModules registers extended modules (e.g. url, buffer) to the plugin's goja runtime.\nfunc EnableExtendModules(p *KernelPlugin, rt *goja.Runtime) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"failed to enable extend modules: %v\", r)\n\t\t}\n\t}()\n\n\tregistry := require.NewRegistry()\n\n\tregistry.Enable(rt)\n\tregistry.RegisterNativeModule(\n\t\tconsole.ModuleName,\n\t\tconsole.RequireWithPrinter(&Printer{name: p.Name}),\n\t)\n\n\turl.Enable(rt)\n\tbuffer.Enable(rt)\n\tconsole.Enable(rt)\n\treturn\n}\n\n// EnableSiyuanModule injects all siyuan.* APIs into the plugin's goja global context.","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/plugin/sandbox.go#L61-L97","documentation":"A recovered panic from EnableExtendModules, which registers require/console/url/buffer modules on the plugin's goja runtime. Any panic during registry.Enable, console registration, or url/buffer Enable is caught by the deferred recover and surfaced as this wrapped error during plugin load.","triggerScenarios":"A plugin load fails because a module registration panicked, e.g. runtime already had a conflicting require registry, a native module returned an error inside goja, or a corrupt plugin context.","commonSituations":"Seen at plugin activation time. Usually indicates a kernel/plugin compatibility mismatch or a double-initialization of the same runtime.","solutions":["Check the kernel log for the underlying panic value (the 'failed to enable extend modules: <panic>' line).","Reinstall/update the plugin and the kernel to matching versions.","Disable other plugins to rule out a global-state collision, then re-enable one at a time.","Report the panic detail to the issue tracker if it persists on a clean profile."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// load-time; cannot retry meaningfully from plugin JS\n// capture in the plugin loader and report\ncatchLoadError(e) { if (/enable extend modules/.test(String(e))) report(e); }","preventionTips":["Keep kernel and plugins on compatible versions.","Disable plugins one at a time to find conflicts.","Report the inner panic value to maintainers."],"tags":["plugin","sandbox","load","panic","internal-bug"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}