grafana/k6 · error
emulating network conditions
Error message
emulating network conditions: %w
What it means
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).
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/network_manager.go:1061 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/81275bd4ef4c7138.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/network_manager.go:1061
return nil
}
// SetOfflineMode toggles offline mode on/off.
func (m *NetworkManager) SetOfflineMode(offline bool) error {
if m.offline == offline {
return nil
}
m.offline = offline
action := network.EmulateNetworkConditions(
m.offline,
m.networkProfile.Latency,
m.networkProfile.Download,
m.networkProfile.Upload,
)
if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
return fmt.Errorf("emulating network conditions: %w", err)
}
return nil
}
// ThrottleNetwork changes the network attributes in chrome to simulate slower
// networks e.g. a slow 3G connection.
func (m *NetworkManager) ThrottleNetwork(networkProfile NetworkProfile) error {
if m.networkProfile == networkProfile {
return nil
}
m.networkProfile = networkProfile
action := network.EmulateNetworkConditions(
m.offline,
m.networkProfile.Latency,
m.networkProfile.Download,
m.networkProfile.Upload,View on GitHub (pinned to 8d06114777)