siyuan-note/siyuan · error

RunScript: %v

Error message

RunScript: %v

What it means

The final step of plugin runtime initialization is `rt.RunScript(p.file, p.Kernel.JS)`, which evaluates the plugin's bundled kernel.js. Any JavaScript syntax error, thrown top-level exception, or Go-side evaluation error is wrapped as `RunScript: %v`. This is the most common plugin startup failure: the plugin's own code failed to execute.

Source

Thrown at kernel/plugin/plugin.go:210

				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.
func (p *KernelPlugin) Eval(rt *goja.Runtime, code string) (goja.Value, error) {
	return rt.RunScript(p.file, code)
}

// close interrupts the goja runtime and clears the pointer.
func (p *KernelPlugin) close() (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("goja panic during close runtime: %v", r)
		}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Read the wrapped goja exception message — it names the line/position in kernel.js that failed
  2. Check the plugin's kernel.js does not reference browser-only globals at top level
  3. Reinstall/update the plugin to get an intact, kernel-compatible bundle
  4. If the inner error mentions unsupported syntax, downgrade the plugin or wait for a kernel goja upgrade

Example fix

// before (plugin kernel.js)
const name = window.location.hostname;
// after
const name = typeof window !== 'undefined' ? window.location.hostname : '';
Defensive patterns

Strategy: try-catch

Validate before calling

// sanity check the bundle before enabling
if (!kernelJs || kernelJs.trim().length === 0) throw new Error('kernel.js is empty; reinstall the plugin');

Try / catch

try { rt.RunScript(p.file, p.Kernel.JS); } catch (e) { console.error('plugin kernel.js failed:', e.message); }

Prevention

When it happens

Trigger: Evaluating the plugin's kernel.js that contains ES syntax goja does not support (e.g. some optional chaining patterns in older versions), a top-level `throw`, or a top-level access to an undefined global.

Common situations: A plugin built for the frontend bundled incorrectly for the kernel (uses browser APIs like `window`/`document` at top level), a corrupted download of the plugin package, or a plugin targeting a newer goja/ES feature than the kernel supports.

Related errors


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