siyuan-note/siyuan · warning
goja panic during close runtime: %v
Error message
goja panic during close runtime: %v
What it means
`KernelPlugin.close` stops the plugin's goja event loop via `runtime.Stop()`. A Go panic during this shutdown (e.g. stopping an already-stopped or mid-callback event loop) is recovered and returned as `goja panic during close runtime: %v`. It indicates a problem tearing down the plugin runtime, usually during plugin stop or error handling.
Source
Thrown at kernel/plugin/plugin.go:227
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)
}
}()
runtime := p.runtime
p.runtime = nil
if runtime != nil {
runtime.Stop() // Stops the event loop and waits for it to finish.
// p.runtime.Terminate() // Interrupts the runtime and causes all executing code to throw an exception.
}
return
}
// error sets the plugin state to errored and frees the goja runtime.
func (p *KernelPlugin) error() {
if p.cancel != nil {
p.cancel()
}
p.closeStorageWatcher()View on GitHub (pinned to 8641553a1f)
Solutions
- Check logs for a preceding plugin error that triggered this during error handling
- Avoid rapid enable/disable toggling of the plugin
- Restart the SiYuan kernel to clear stuck runtimes
- If reproducible, report with the panic value and plugin name
Defensive patterns
Strategy: try-catch
Try / catch
if err := plugin.Stop(); err != nil { log.Warnf("plugin stop reported: %v (runtime may already be closed)", err) } Prevention
- Avoid toggling plugin enable/disable in rapid succession
- Let in-flight async tasks finish before stopping plugins
- Treat close errors during shutdown as non-fatal warnings
- Restart the kernel if runtimes appear stuck
When it happens
Trigger: Calling close() when the event loop is in an unexpected state — double stop, Stop racing with a pending worker task, or a panic inside eventloop.Stop due to runtime inconsistency.
Common situations: Rapid disable/enable cycles on the same plugin, a plugin error path calling p.error() which invokes close while the loop is already terminating, or kernel shutdown while plugins are mid-callback.
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
- goja panic during event loop run: %v
- goja panic during start: %v
- injectAgent: %v
- injectPlugin: %v
- injectRpc: %v
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/5dc9d929cc0470f4.
Report an issue: GitHub.