siyuan-note/siyuan · error
injectServer
Error message
injectServer: %v
What it means
injectServer adds the siyuan.server (http/ws/es) API surface to the plugin's goja runtime. Any panic during that setup is recovered and reported as 'injectServer: %v'. The plugin fails to load with the server API available; it is an initialization-time failure, not a per-request error.
Solutions
- Inspect the wrapped cause (%v) and kernel logs at plugin load time
- Restart the kernel and reload the plugin to retry injection
- Update kernel and plugin to compatible versions
- If reproducible, report with the panic cause from the logs
Defensive patterns
Strategy: try-catch
Try / catch
try { useServerApi() } catch (e) { if (String(e.message).startsWith('injectServer:')) { /* server API unavailable */ } throw e } Prevention
- Verify plugin API surface availability before use (feature-detect siyuan.server)
- Update kernel/plugin together
- Watch kernel logs during plugin load for injection panics
When it happens
Trigger: Panic while creating or registering the http/ws/es objects during plugin runtime bootstrap.
Common situations: Kernel-side server wiring unavailable or misconfigured at plugin load; property registration conflicts on the siyuan object; a kernel bug introduced in a plugin API update.
Related errors
- injectSecretsVars
- encrypted notebook lock callbacks are not initialized
- failed to run task on event loop
- initialize encrypted notebook document failed
- 26
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/faed84e0c4f08e4b.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/plugin/api_server.go:30
// GNU Affero General Public License for more details.
//
// 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"
)
// injectServer adds siyuan.server to the goja context.
func injectServer(p *KernelPlugin, rt *goja.Runtime, siyuan *goja.Object) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("injectServer: %v", r)
}
}()
http := rt.NewObject()
ws := rt.NewObject()
es := rt.NewObject()
lo.Must0(http.Set("handler", goja.Null()))
lo.Must0(ws.Set("handler", goja.Null()))
lo.Must0(es.Set("handler", goja.Null()))
lo.Must0(ObjectSeal(rt, http))
lo.Must0(ObjectSeal(rt, ws))
lo.Must0(ObjectSeal(rt, es))
private := rt.NewObject()
lo.Must0(private.Set(string(RequestTypeHTTP), http))View on GitHub (pinned to 9f775e8a12)