siyuan-note/siyuan · error

EnableExtendModules: %v

Error message

EnableExtendModules: %v

What it means

When initializing a plugin's goja runtime, the kernel first registers the extend modules (RPC, sockets, etc.) via `EnableExtendModules`. If that registration returns an error, it is wrapped as `EnableExtendModules: %v` and plugin startup fails. It means one of the extended API surfaces could not be installed into the plugin's JS runtime.

Source

Thrown at kernel/plugin/plugin.go:200

}

// InitRuntime initializes the goja runtime and evaluates kernel.js.
func (p *KernelPlugin) InitRuntime() (err error) {
	p.runtime = eventloop.NewEventLoop(eventloop.EnableConsole(true))
	p.worker.Start(p.runtime)

	p.runtime.Run(func(rt *goja.Runtime) {
		defer func() {
			if r := recover(); r != nil {
				err = fmt.Errorf("goja panic during event loop run: %v", r)
			}
		}()

		// Use JSON struct tags for field name mapping, with fallback to original names if "json" tag is absent.
		rt.SetFieldNameMapper(goja.TagFieldNameMapper("json", true))

		if enableErr := EnableExtendModules(p, rt); enableErr != nil {
			err = fmt.Errorf("EnableExtendModules: %v", enableErr)
			return
		}

		if enableErr := EnableSiyuanModule(p, rt); enableErr != nil {
			err = fmt.Errorf("EnableSiyuanModule: %v", enableErr)
			return
		}

		if _, runErr := rt.RunScript(p.file, p.Kernel.JS); runErr != nil {
			err = fmt.Errorf("RunScript: %v", runErr)
			return
		}
	})
	p.runtime.Start()
	return
}

// Eval evaluates JavaScript code in the plugin's goja runtime, returning the result or error.

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Inspect the wrapped inner error in the log for the specific module that failed to enable
  2. Restart the plugin to rule out a duplicate-start race
  3. Update SiYuan kernel if the inner error points at module registration code
  4. Report with plugin name and full error if reproducible
Defensive patterns

Strategy: fallback

Try / catch

if err := plugin.Start(); err != nil && strings.Contains(err.Error(), "EnableExtendModules") { // disable plugin and retry once after restart }

Prevention

When it happens

Trigger: Any error returned by EnableExtendModules during InitRuntime — e.g. lo.Must assertions on module property registration failing, or a sub-registration (RPC method table, socket API) returning an error.

Common situations: Kernel-side bugs after an upgrade where module registration code asserts on frozen objects, or a plugin started twice concurrently so runtime state is inconsistent.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/0f7a4d010e12369a. Report an issue: GitHub.