siyuan-note/siyuan · error
injectRpc: %v
Error message
injectRpc: %v
What it means
injectRpc installs the siyuan.rpc object (bind/unbind/call) into the plugin's goja runtime. Any panic during this setup is recovered and wrapped as 'injectRpc: %v', aborting RPC registration for that plugin.
Source
Thrown at kernel/plugin/api_rpc.go:32
// 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"
"github.com/siyuan-note/siyuan/kernel/util"
)
// injectRpc adds siyuan.rpc method for RPC method registration.
func injectRpc(p *KernelPlugin, rt *goja.Runtime, siyuan *goja.Object) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("injectRpc: %v", r)
}
}()
rpc := rt.NewObject()
lo.Must0(rpc.Set("bind", rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
promise, resolve, reject := rt.NewPromise()
var argErr error
var name string
var method goja.Callable
var descriptions []string
if len(call.Arguments) < 2 {
argErr = fmt.Errorf("method name and function required")
} else {
nameArg := call.Argument(0)
methodArg := call.Argument(1)
descArgs := call.Arguments[2:]View on GitHub (pinned to 8641553a1f)
Solutions
- Inspect the wrapped %v message for the underlying panic cause
- Ensure the goja runtime is healthy and not closed before injectRpc
- Retry plugin load; if deterministic, debug kernel/plugin/api_rpc.go
- Confirm lo.Must0 assertions on rpc.Set succeed (no duplicate/conflicting property definitions)
Defensive patterns
Strategy: try-catch
Validate before calling
if (typeof rt === "undefined" || rt === null) {
throw new Error("runtime unavailable before rpc injection");
} Try / catch
try {
await registerRpc(plugin);
} catch (e) {
if (String(e).startsWith("injectRpc:")) {
console.error("rpc injection failed:", e);
}
} Prevention
- Ensure the runtime is not closed/corrupted during bootstrap
- Retry plugin load once on transient runtime failures
- Report deterministic panics to the kernel maintainers
When it happens
Trigger: A panic occurs while creating the rpc object or setting its bind method value in the goja runtime — e.g. corrupted runtime or nil pointers during object construction.
Common situations: Plugin bootstrap failure where the runtime is in an unexpected state; usually a kernel-side/internal issue rather than a plugin-author mistake.
Related errors
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/df7cc7b4c683b3f3.
Report an issue: GitHub.