siyuan-note/siyuan · critical

goja panic during start: %v

Error message

goja panic during start: %v

What it means

`KernelPlugin.start` wraps its whole body in a recover; any Go panic during plugin startup (state updates, directory creation, runtime init, event subscription, load callbacks) is converted to `goja panic during start: %v`, the plugin is moved to PluginStateError, and its runtime/capabilities are cleaned up. This is the outermost safety net for the plugin boot sequence.

Source

Thrown at kernel/plugin/plugin.go:259

func (p *KernelPlugin) error() {
	if p.cancel != nil {
		p.cancel()
	}
	p.closeStorageWatcher()
	p.Clear()

	if err := p.close(); err != nil {
		logging.LogErrorf("[plugin:%s] failed to close runtime during error handling: %v", p.Name, err)
	}

	p.updateState(PluginStateError)
}

// start creates the goja runtime, injects sandbox globals, and evaluates kernel.js.
func (p *KernelPlugin) start() (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("goja panic during start: %v", r)
		}
		if err != nil {
			p.error()
		}
	}()

	p.updateState(PluginStateLoading)

	baseDir := filepath.Join(util.DataDir, "storage", "petal", p.Name)
	if err := os.MkdirAll(baseDir, 0755); err != nil {
		return fmt.Errorf("create plugin dir [%s] failed: %s", baseDir, err)
	}

	if runtimeErr := p.InitRuntime(); runtimeErr != nil {
		return fmt.Errorf("start runtime: %v", runtimeErr)
	}

	if subscribeErr := p.subscribeEventHandlers(); subscribeErr != nil {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Read the panic value to locate the failing startup step
  2. Check plugin log output immediately before the panic for the actual JS/Go failure
  3. Disable the problematic plugin to restore stability, then update or reinstall it
  4. Report with plugin name and full panic message if reproducible
Defensive patterns

Strategy: try-catch

Try / catch

if err := StartPlugin(p); err != nil { log.Errorf("plugin %s failed to start: %v", p.Name, err); /* plugin is already in error state; skip it */ }

Prevention

When it happens

Trigger: A panic anywhere in start() — e.g. inside p.onLoad()/onRunning() callbacks that invoke plugin JS, or during PushKernelPluginState — before the more specific wrapped errors (1698/1699) are produced.

Common situations: A plugin's load hook throwing a Go-level panic in goja, nil pointers in state publishing after kernel upgrade, or concurrent StartPlugin calls on the same plugin instance.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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