{"record":{"id":"30efa46b83213fe4","repo":"slackhq/nebula","slug":"ienumnetworkconnections-next-s","errorCode":null,"errorMessage":"IEnumNetworkConnections.Next: %s","messagePattern":"IEnumNetworkConnections\\.Next: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"overlay/network_category_windows.go","lineNumber":157,"sourceCode":"\tClone   uintptr\n}\n\ntype iEnumNetworkConnections struct{ Vtbl *iEnumNetworkConnectionsVtbl }\n\nfunc (e *iEnumNetworkConnections) Release() {\n\tsyscall.SyscallN(e.Vtbl.Release, uintptr(unsafe.Pointer(e)))\n}\n\n// Next returns the next connection, or (nil, nil) at the end of the enumeration.\nfunc (e *iEnumNetworkConnections) Next() (*iNetworkConnection, error) {\n\tvar conn *iNetworkConnection\n\tvar fetched uint32\n\tr1, _, _ := syscall.SyscallN(e.Vtbl.Next,\n\t\tuintptr(unsafe.Pointer(e)), 1,\n\t\tuintptr(unsafe.Pointer(&conn)), uintptr(unsafe.Pointer(&fetched)),\n\t)\n\tif hr := hresult(r1); hr.failed() {\n\t\treturn nil, fmt.Errorf(\"IEnumNetworkConnections.Next: %s\", hr)\n\t}\n\tif fetched == 0 {\n\t\treturn nil, nil\n\t}\n\treturn conn, nil\n}\n\ntype iNetworkConnectionVtbl struct {\n\tiDispatchVtbl\n\tGetNetwork            uintptr\n\tIsConnectedToInternet uintptr\n\tIsConnected           uintptr\n\tGetConnectivity       uintptr\n\tGetConnectionId       uintptr\n\tGetAdapterId          uintptr\n\tGetDomainType         uintptr\n}\n","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/overlay/network_category_windows.go#L139-L175","documentation":"This error wraps a failed HRESULT from IEnumNetworkConnections::Next, which advances the COM enumerator of network connections. It occurs while iterating NLM connections during network category detection on Windows; a failing HRESULT indicates the enumerator became invalid or the COM infrastructure rejected the call. fetched==0 with a successful HRESULT is the normal end-of-enumeration case and returns nil, not this error.","triggerScenarios":"Calling Next() on an iEnumNetworkConnections obtained from INetworkListManager.GetNetworkConnections when the underlying enumerator is stale/freed or the COM runtime returns a failure HRESULT mid-iteration.","commonSituations":"Enumerating after the NLM service went away mid-scan; COM threading violations (enumerator created on a different apartment/thread); system shutting down or network stack being restarted during tunnel setup.","solutions":["Perform enumeration on the same OS thread where COM was initialized and the enumerator was created (lock OS thread / pass the enumerator carefully across threads)","Retry the scan after the network stack settles (e.g. netprofm restarting)","Check the formatted hresult to identify the COM failure code and address it specifically","Treat the failure as a warning and skip network-category classification rather than failing tunnel startup"],"exampleFix":"// before\nconn, err := e.Next()\nif err != nil { return err }\n// after\nconn, err := e.Next()\nif err != nil {\n    l.WithError(err).Warn(\"network connection enumeration failed; skipping category detection\")\n    return nil\n}","handlingStrategy":"try-catch","validationCode":"// ensure enumeration happens on the COM-initialized thread\nruntime.LockOSThread()\ndefer runtime.UnlockOSThread()\nif err := coInit(); err != nil { return err }\ndefer coUninit()","typeGuard":"func isEnumNextError(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"IEnumNetworkConnections.Next:\")\n}","tryCatchPattern":"conn, err := enum.Next()\nif err != nil {\n    if isEnumNextError(err) {\n        log.Warnf(\"enumerator failed mid-scan, aborting category detection: %v\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Never share COM enumerators across threads/apartments","Complete enumeration quickly to avoid service restarts mid-scan","Retry the whole scan (get enumerator + iterate) rather than a single Next call","Treat mid-iteration COM failures as transient"],"tags":["windows","com","winapi","enumeration"],"backgroundTag":"com-call-failed","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}