MHSanaei/3x-ui · error

runtime manager unavailable

Error message

runtime manager unavailable

What it means

GetWebCertFiles asks the node runtime layer (internal/web/runtime) for a Manager before dialing a node to read its cert paths. GetManager() returns the package-level manager set by SetManager(); if it is nil, the multi-node runtime was never initialized in this process, so no node RPC is possible. This is an initialization-order defect, not a network failure.

Source

Thrown at internal/web/service/node.go:780

		mgr.InvalidateNode(id)
	}
	return nil
}

// GetWebCertFiles asks a node for its own web TLS certificate/key file paths,
// used by "Set Cert from Panel" so a node-assigned inbound gets paths that
// exist on the node rather than the central panel. See issue #4854.
func (s *NodeService) GetWebCertFiles(id int) (*runtime.WebCertFiles, error) {
	n, err := s.GetById(id)
	if err != nil || n == nil {
		return nil, fmt.Errorf("node not found")
	}
	if !n.Enable {
		return nil, fmt.Errorf("node is disabled")
	}
	mgr := runtime.GetManager()
	if mgr == nil {
		return nil, fmt.Errorf("runtime manager unavailable")
	}
	remote, err := mgr.RemoteFor(n)
	if err != nil {
		return nil, err
	}
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()
	return remote.GetWebCertFiles(ctx)
}

// NodeUpdateResult reports the outcome of triggering a panel self-update on one
// node so the UI can show per-node success/failure for a bulk request.
type NodeUpdateResult struct {
	Id    int    `json:"id"`
	Name  string `json:"name"`
	OK    bool   `json:"ok"`
	Error string `json:"error,omitempty"`
}

View on GitHub (pinned to ad32144c42)

Solutions

  1. Verify panel startup logs for a failed runtime/Manager initialization and fix the underlying init error
  2. If this is a test, call runtime.SetManager(runtime.NewManager(...)) (or the project's helper) before invoking GetWebCertFiles
  3. Confirm the call is not racing startup — retry after the panel is fully booted
  4. Check that the node feature is actually compiled/enabled in this build

Example fix

// before
svc := service.NewNodeService(...)
files, err := svc.GetWebCertFiles(1) // runtime manager unavailable

// after
runtime.SetManager(runtime.NewManager(db)) // during app/test init
files, err := svc.GetWebCertFiles(1)
Defensive patterns

Strategy: validation

Validate before calling

import "github.com/mhsanaeti/3x-ui/v3/internal/web/runtime"

if runtime.GetManager() == nil {
    // initialize or refuse before calling GetWebCertFiles
    return errors.New("node runtime not initialized; start it first")
}
files, err := svc.GetWebCertFiles(nodeID)

Try / catch

files, err := svc.GetWebCertFiles(id)
if err != nil {
    if strings.Contains(err.Error(), "runtime manager unavailable") {
        // surface 'panel node subsystem not ready' to the UI, suggest restart
    }
    return err
}

Prevention

When it happens

Trigger: Calling the 'Set Cert from Panel' flow (GetWebCertFiles(id)) on a panel whose startup did not call runtime.SetManager — e.g. the node subsystem failed to initialize, the call races panel startup, or a test/unit harness invokes NodeService without registering a Manager.

Common situations: Custom test setups that construct NodeService directly against a throwaway DB; a crashed or skipped runtime init during boot; invoking the service before the web server finished initializing node sync.

Related errors


AI-assisted analysis of MHSanaei/3x-ui@ad32144c42 (2026-08-15). Data as JSON: /api/errors/0720a4d6607acae9. Report an issue: GitHub.