siyuan-note/siyuan · error
injectEvent: %v
Error message
injectEvent: %v
What it means
injectEvent installs the siyuan.event object into the plugin's goja runtime; this error wraps any panic occurring during that installation. A panic here usually means something went wrong while creating or registering the event API objects (e.g. the worker runtime is in a broken state or a required object failed to set). The error is reported to the plugin loader and typically aborts that injection step.
Source
Thrown at kernel/plugin/api_event.go:31
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package plugin
import (
"fmt"
"github.com/dop251/goja"
"github.com/samber/lo"
"github.com/siyuan-note/logging"
)
// injectEvent adds siyuan.event to the goja context.
func injectEvent(p *KernelPlugin, rt *goja.Runtime, siyuan *goja.Object) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("injectEvent: %v", r)
}
}()
event := rt.NewObject()
lo.Must0(event.Set("handler", goja.Null()))
lo.Must0(event.Set("emit", rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
promise, resolve, reject := rt.NewPromise()
var argErr error
var topic string
var eventData any
if len(call.Arguments) < 2 {
argErr = fmt.Errorf("topic and event required")
} else {
topic = call.Argument(0).String()
if topic == "" {View on GitHub (pinned to 8641553a1f)
Solutions
- Restart the kernel/plugin host so a fresh goja runtime is used
- Update the kernel — this is an internal setup fault, not user-fixable in plugin code
- Check kernel logs for the wrapped panic detail (%v) to identify the failing registration
- Disable recently installed plugins to isolate a plugin that corrupts the worker
Defensive patterns
Strategy: try-catch
Try / catch
try { startPluginRuntime(); } catch (e) { if (String(e).startsWith("injectEvent:")) { restartKernelPluginHost(); } else { throw e; } } Prevention
- Keep kernel updated — this is an internal bootstrap fault
- Avoid terminating the plugin worker during injection
- Reproduce via kernel logs showing the wrapped panic value
- Isolate misbehaving plugins that may corrupt the runtime
When it happens
Trigger: Panic raised by rt.NewObject(), event.Set(...), or surrounding code while adding siyuan.event during plugin runtime bootstrap; a goja runtime that is shutting down or corrupted.
Common situations: Kernel-side regression in API setup; plugin worker terminated concurrently with injection; malformed plugin bootstrap sequence causing injection on a dead runtime.
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
- injectLogger: %v
- injectClient: %v
- injectServer: %v
- injectStorage: %v
- panic during siyuan.storage.put: %v
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/ba5e2809c0604275.
Report an issue: GitHub.