siyuan-note/siyuan · error

injectServer: %v

Error message

injectServer: %v

What it means

injectServer installs the siyuan.server object (http/ws/es handler slots) into a kernel plugin's goja runtime. A panic inside the injection (e.g. lo.Must0 failing because a property could not be set on a sealed object, or goja runtime misuse) is recovered and wrapped as "injectServer: %v". The plugin load then fails with this error. It indicates a kernel-side injection failure, not a problem in the plugin's JavaScript code.

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 8641553a1f)

Solutions

  1. Check the full log line for the wrapped panic message to identify the actual panic cause
  2. Restart SiYuan and re-enable the plugin; corrupted goja runtime state is transient
  3. Update SiYuan to the latest version; this is an internal injection path likely fixed upstream
  4. If reproducible, disable the offending plugin and file an issue with the stack trace
Defensive patterns

Strategy: try-catch

Try / catch

// Kernel-side Go code loading the plugin
if err := injectServer(p, rt, siyuan); err != nil {
    return fmt.Errorf("plugin %s load failed: %w", p.Name, err)
}

Prevention

When it happens

Trigger: A panic during injectServer: lo.Must0 sees a non-nil error from Object.Set / ObjectSeal / ObjectFreeze / siyuan.Set (e.g. the target object is already sealed or the runtime is in a broken state), or any unexpected panic inside the function while loading the plugin.

Common situations: Kernel/plugin host bug or a corrupted plugin runtime state during plugin load; typically hit during SiYuan startup or when enabling a kernel plugin after an abnormal shutdown; rarely caused by user configuration.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/faed84e0c4f08e4b. Report an issue: GitHub.