siyuan-note/siyuan · error
invalid event object
Error message
invalid event object
What it means
Panicked when the SSE port.send() first argument is null/undefined OR is a value that cannot be turned into an object (ToObject returns nil). Distinct from missing-data: this means there is no usable event object at all to read fields from.
Source
Thrown at kernel/plugin/plugin.go:1403
}
if event := eventObj.Get("event"); goja.IsString(event) {
e.Event = event.String()
}
if id := eventObj.Get("id"); goja.IsString(id) {
e.Id = id.String()
}
if retry := eventObj.Get("retry"); goja.IsNumber(retry) {
e.Retry = uint(retry.ToInteger())
}
events.In <- e
return goja.Undefined()
}
}
panic(rt.NewGoError(fmt.Errorf("invalid event object")))
})
port_close := rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
doClose()
return goja.Undefined()
})
lo.Must0(port.Set("onopen", goja.Null()))
lo.Must0(port.Set("onclose", goja.Null()))
lo.Must0(port.Set("send", port_send))
lo.Must0(port.Set("close", port_close))
lo.Must0(ObjectSeal(rt, port))
lo.Must0(jsRequestObj.Set("port", port))
invokeFunction(func(_ *goja.Runtime, result *CallResult) {View on GitHub (pinned to 251596fc0d)
Solutions
- Always pass an event object: port.send({ data: '...' }).
- Use port.close() to end the stream instead of an empty send.
- Guard: if (!event) return; before port.send(event).
Example fix
// before
port.send(maybeEvent);
// after
if (maybeEvent && typeof maybeEvent === 'object' && 'data' in maybeEvent) {
port.send(maybeEvent);
} Defensive patterns
Strategy: type-guard
Validate before calling
function isValidEventObject(e: unknown): boolean { return !!e && typeof e === 'object'; } Type guard
function isEventObject(e: unknown): e is { data: unknown; event?: string; id?: string; retry?: number } { return !!e && typeof e === 'object' && 'data' in (e as any); } Try / catch
if (!isValidEventObject(event)) return; try { port.send(event); } catch (e) { /* ... */ } Prevention
- Never call send() with null/undefined/empty args.
- Guard optional event variables before sending.
- Use port.close() to end the stream, not an empty send.
When it happens
Trigger: Calling port.send(), port.send(null), or port.send(undefined); or passing a primitive (number/string) where an event object is expected.
Common situations: Forwarding an optional event variable that is sometimes undefined, or calling send with no args to 'ping' the stream.
Related errors
- event.data is required
- Agent capability name and description are required
- plugin [%s] not found
- registerCapability requires 3 arguments: name, config, handl
- capability name must not be empty
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/4017554ae1d80700.
Report an issue: GitHub.