siyuan-note/siyuan · error
injectRpc
Error message
injectRpc: %v
What it means
injectRpc registers the siyuan.rpc object (used to bind plugin-provided RPC methods) into the plugin's goja runtime. Any Go panic during registration is recovered and surfaced as this error, meaning RPC method registration could not be set up for the plugin.
Solutions
- Inspect the wrapped %v detail and report it upstream with the plugin name
- Update the kernel to the latest version
- Retry loading the plugin to rule out a transient failure
- Disable other plugins to rule out interference during initialization
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
await loadPlugin(p);
} catch (e) {
if (String(e.message).startsWith('injectRpc:')) {
console.error('RPC API failed to install:', e.message);
}
} Prevention
- Keep the kernel updated
- Feature-check siyuan.rpc before binding methods
- Include the wrapped panic detail in bug reports
When it happens
Trigger: A panic inside rt.NewObject() or the rpc.Set('bind', ...) binding while the kernel initializes the plugin runtime.
Common situations: Kernel-side defects during plugin bootstrap; seen when a plugin that registers RPC methods fails to load.
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
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/df7cc7b4c683b3f3.
Report an issue: GitHub.
Appendix: 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 9f775e8a12)