{"record":{"id":"0720a4d6607acae9","repo":"MHSanaei/3x-ui","slug":"runtime-manager-unavailable","errorCode":null,"errorMessage":"runtime manager unavailable","messagePattern":"runtime manager unavailable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/web/service/node.go","lineNumber":780,"sourceCode":"\t\tmgr.InvalidateNode(id)\n\t}\n\treturn nil\n}\n\n// GetWebCertFiles asks a node for its own web TLS certificate/key file paths,\n// used by \"Set Cert from Panel\" so a node-assigned inbound gets paths that\n// exist on the node rather than the central panel. See issue #4854.\nfunc (s *NodeService) GetWebCertFiles(id int) (*runtime.WebCertFiles, error) {\n\tn, err := s.GetById(id)\n\tif err != nil || n == nil {\n\t\treturn nil, fmt.Errorf(\"node not found\")\n\t}\n\tif !n.Enable {\n\t\treturn nil, fmt.Errorf(\"node is disabled\")\n\t}\n\tmgr := runtime.GetManager()\n\tif mgr == nil {\n\t\treturn nil, fmt.Errorf(\"runtime manager unavailable\")\n\t}\n\tremote, err := mgr.RemoteFor(n)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\treturn remote.GetWebCertFiles(ctx)\n}\n\n// NodeUpdateResult reports the outcome of triggering a panel self-update on one\n// node so the UI can show per-node success/failure for a bulk request.\ntype NodeUpdateResult struct {\n\tId    int    `json:\"id\"`\n\tName  string `json:\"name\"`\n\tOK    bool   `json:\"ok\"`\n\tError string `json:\"error,omitempty\"`\n}","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/web/service/node.go#L762-L798","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify panel startup logs for a failed runtime/Manager initialization and fix the underlying init error","If this is a test, call runtime.SetManager(runtime.NewManager(...)) (or the project's helper) before invoking GetWebCertFiles","Confirm the call is not racing startup — retry after the panel is fully booted","Check that the node feature is actually compiled/enabled in this build"],"exampleFix":"// before\nsvc := service.NewNodeService(...)\nfiles, err := svc.GetWebCertFiles(1) // runtime manager unavailable\n\n// after\nruntime.SetManager(runtime.NewManager(db)) // during app/test init\nfiles, err := svc.GetWebCertFiles(1)","handlingStrategy":"validation","validationCode":"import \"github.com/mhsanaeti/3x-ui/v3/internal/web/runtime\"\n\nif runtime.GetManager() == nil {\n    // initialize or refuse before calling GetWebCertFiles\n    return errors.New(\"node runtime not initialized; start it first\")\n}\nfiles, err := svc.GetWebCertFiles(nodeID)","typeGuard":null,"tryCatchPattern":"files, err := svc.GetWebCertFiles(id)\nif err != nil {\n    if strings.Contains(err.Error(), \"runtime manager unavailable\") {\n        // surface 'panel node subsystem not ready' to the UI, suggest restart\n    }\n    return err\n}","preventionTips":["Ensure app startup always calls runtime.SetManager before serving node APIs","In tests, register a Manager in TestMain or a helper before exercising NodeService"],"tags":["runtime","initialization","multi-node","certificates"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}