siyuan-note/siyuan · critical

goja panic during event loop run: %v

Error message

goja panic during event loop run: %v

What it means

During plugin startup, `InitRuntime` runs a setup function inside the plugin's goja event loop. A Go-level panic raised anywhere in that setup (field-name mapper installation, module registration, etc.) is recovered and reported as `goja panic during event loop run: %v`. This is a fatal plugin initialization failure — the plugin's runtime never gets its modules or script loaded.

Source

Thrown at kernel/plugin/plugin.go:192

	})
	p.agentCapabilities.Clear()
}

// updateState updates the plugin state atomically and pushes the new state to the frontend via util.PushKernelPluginState.
func (p *KernelPlugin) updateState(state PluginState) {
	p.state.Store(int64(state))
	util.PushKernelPluginState(p.Name, int(state))
}

// 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)

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Read the panic value in the message to find the nil/invalid value source in the kernel code
  2. Verify the plugin's kernel.js content was downloaded/loaded intact (not empty or truncated)
  3. Restart the plugin (disable then enable) to rule out a transient race during start
  4. Update SiYuan; if reproducible, file an issue with the panic message and plugin name
Defensive patterns

Strategy: fallback

Try / catch

if err := plugin.Start(); err != nil { log.Warnf("plugin failed to init: %v; skipping", err) }

Prevention

When it happens

Trigger: A panic inside the `rt.Run(func(rt *goja.Runtime){...})` body during `InitRuntime` — typically a nil pointer or lo.Must assertion failure while registering extend/siyuan modules, before the Enable* wrappers convert their own errors.

Common situations: A kernel build with mismatched goja/eventloop versions, a plugin descriptor (Kernel.JS) that is nil or malformed causing script access panics, or concurrent start/stop of the same plugin racing on the runtime.

Related errors


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