{"record":{"id":"9e9e6697f297bd02","repo":"netbirdio/netbird","slug":"ipc-get-w","errorCode":null,"errorMessage":"ipc get: %w","messagePattern":"ipc get: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/iface/configurer/usp.go","lineNumber":361,"sourceCode":"\t\t}\n\t}\n\n\tif runtime.GOOS == \"linux\" {\n\t\tsockPath := \"/var/run/wireguard/\" + t.deviceName + \".sock\"\n\t\tif _, statErr := os.Stat(sockPath); statErr == nil {\n\t\t\t_ = os.Remove(sockPath)\n\t\t}\n\t}\n}\n\nfunc (t *WGUSPConfigurer) GetStats() (map[string]WGStats, error) {\n\treturn t.statsCache.get()\n}\n\nfunc (t *WGUSPConfigurer) fetchStats() (map[string]WGStats, error) {\n\tipc, err := t.device.IpcGet()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ipc get: %w\", err)\n\t}\n\n\treturn parseTransfers(ipc)\n}\n\nfunc parseTransfers(ipc string) (map[string]WGStats, error) {\n\tstats := make(map[string]WGStats)\n\tvar (\n\t\tcurrentKey   string\n\t\tcurrentStats WGStats\n\t\thasPeer      bool\n\t)\n\tlines := strings.Split(ipc, \"\\n\")\n\tfor _, line := range lines {\n\t\tline = strings.TrimSpace(line)\n\n\t\t// If we're within the details of the found peer and encounter another public key,\n\t\t// this means we're starting another peer's details. So, stop.","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/configurer/usp.go#L343-L379","documentation":"WGUSPConfigurer.fetchStats, the periodic refresher behind GetStats' stats cache, failed to read the device state with device.IpcGet(). It occurs when the wireguard-go device is closed or its state is unavailable at the moment the cache TTL expires. GetStats propagates it, so monitoring sees repeated failures until the device is running again.","triggerScenarios":"Cache refresh firing after device Close but before the configurer is discarded; reconnect window where the old device is gone and the new one is not yet up; internal UAPI serialization error during a heavy load spike.","commonSituations":"Frequent reconnects on unreliable links causing device churn; agent shutdown with a stats poller still attached; netstack/embedded deployments with short-lived devices.","solutions":["Drop the configurer (and its cache) when the device is replaced so stale fetchers stop running","Return the cached snapshot or an empty map on fetch failure instead of erroring every poll","Retry the fetch after the new device signals readiness","Stop stats pollers before closing the device in shutdown order"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"stats, err := uspCfg.GetStats()\nif err != nil {\n\t// device churn between IpcGet and cache refresh: serve last snapshot\n\tlog.Debugf(\"stats fetch failed, serving cached: %v\", err)\n\tstats = lastGoodStats\n}\nreturn stats, nil","preventionTips":["Discard the configurer and its cache when the device is replaced","Serve cached or empty stats on fetch failure instead of propagating every poll","Stop stats pollers before device Close in shutdown order","Rate-limit fetch-failure logging to one line per outage"],"tags":["wireguard-go","stats","cache","uapi","lifecycle"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}