siyuan-note/siyuan · error
method name required
Error message
method name required
What it means
The siyuan.rpc.unbind API removes a previously bound RPC method by name. It requires at least one call argument; when none is provided it rejects the returned promise with 'method name required'. The kernel cannot identify which binding to remove without a name.
Solutions
- Pass the method name string as the first argument: siyuan.rpc.unbind('myMethod')
- Verify the name expression is not undefined before the call
- Guard the call site: only call unbind when a name was actually bound
Example fix
// before
await siyuan.rpc.unbind()
// after
await siyuan.rpc.unbind('myMethod') Defensive patterns
Strategy: validation
Validate before calling
if (typeof name === 'string' && name) { await siyuan.rpc.unbind(name) } Type guard
const hasName = (v) => typeof v === 'string' && v.length > 0
Try / catch
try { await siyuan.rpc.unbind(name) } catch (e) { if (e.message !== 'method name required') throw e } Prevention
- Keep bound method names in a constants list and unbind from it
- Never call unbind with zero arguments
- Track bindings in a Set so unbind is only called for known names
When it happens
Trigger: Calling siyuan.rpc.unbind() with zero arguments.
Common situations: Copy-pasted unbind call where the name argument was deleted; dynamically computing the name and the expression evaluating to undefined so the argument list effectively appears empty in checks; template-string bug producing an empty call.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- method required
- method name and function required
- path required
- second argument must be a function
- assetPath is required for analyze
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/23e6655fbe556796.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/plugin/api_rpc.go:105
}
})
if runErr != nil {
logging.LogErrorf("[plugin:%s] siyuan.rpc.bind worker run: %v", p.Name, runErr)
if rejectErr := reject(rt.NewGoError(runErr)); rejectErr != nil {
logging.LogErrorf("[plugin:%s] siyuan.rpc.bind reject: %v", p.Name, rejectErr)
}
}
return rt.ToValue(promise)
})))
lo.Must0(rpc.Set("unbind", rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
promise, resolve, reject := rt.NewPromise()
var argErr error
var name string
if len(call.Arguments) < 1 {
argErr = fmt.Errorf("method name required")
} else if nameArg := call.Argument(0); goja.IsString(nameArg) {
name = nameArg.String()
} else {
argErr = fmt.Errorf("first argument must be method name string")
}
runErr := p.worker.Run(func(rt *goja.Runtime) (result any, err error) {
if argErr != nil {
err = argErr
return
}
err = p.unbindRpcMethod(name)
return
}, func(rt *goja.Runtime, result any, err error) {
if lo.IsNil(err) {
if resolveErr := resolve(result); resolveErr != nil {
logging.LogErrorf("[plugin:%s] siyuan.rpc.unbind resolve: %v", p.Name, resolveErr)
}View on GitHub (pinned to 9f775e8a12)