{"record":{"id":"81275bd4ef4c7138","repo":"grafana/k6","slug":"emulating-network-conditions-w","errorCode":null,"errorMessage":"emulating network conditions: %w","messagePattern":"emulating network conditions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/network_manager.go","lineNumber":1061,"sourceCode":"\n\treturn nil\n}\n\n// SetOfflineMode toggles offline mode on/off.\nfunc (m *NetworkManager) SetOfflineMode(offline bool) error {\n\tif m.offline == offline {\n\t\treturn nil\n\t}\n\tm.offline = offline\n\n\taction := network.EmulateNetworkConditions(\n\t\tm.offline,\n\t\tm.networkProfile.Latency,\n\t\tm.networkProfile.Download,\n\t\tm.networkProfile.Upload,\n\t)\n\tif err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {\n\t\treturn fmt.Errorf(\"emulating network conditions: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// ThrottleNetwork changes the network attributes in chrome to simulate slower\n// networks e.g. a slow 3G connection.\nfunc (m *NetworkManager) ThrottleNetwork(networkProfile NetworkProfile) error {\n\tif m.networkProfile == networkProfile {\n\t\treturn nil\n\t}\n\tm.networkProfile = networkProfile\n\n\taction := network.EmulateNetworkConditions(\n\t\tm.offline,\n\t\tm.networkProfile.Latency,\n\t\tm.networkProfile.Download,\n\t\tm.networkProfile.Upload,","sourceCodeStart":1043,"sourceCodeEnd":1079,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/common/network_manager.go#L1043-L1079","documentation":"Failure of the CDP Network.emulateNetworkConditions command while toggling offline mode with the current network profile's latency/download/upload values. Skipped entirely if the requested state already matches; the error indicates the browser rejected the emulation command (e.g. closed session).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/network_manager.go:1061 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Toggle offline before closing pages, on an active session","Retry the offline toggle if it raced with page/target setup","Check the wrapped CDP error for connection-level causes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}