grafana/k6 · error
updating offline mode for frame
Error message
updating offline mode for frame %v: %w
What it means
Wrap of a NetworkManager.SetOfflineMode failure for a specific frame target: updateOffline reads the browser context's Offline option and, when it is set (or on non-initial updates), toggles the CDP Network.emulateNetworkConditions state. The error fires when the emulate-network command is rejected — most commonly because the frame's session was already detached during navigation or the browser target crashed. The %v is the frame's target ID.
Solutions
- Confirm the frame still exists and its CDP session is attached before toggling offline mode
- Apply the offline option at browser-context creation instead of changing it mid-navigation
- Retry the operation after the page finishes navigating
- Check browser logs if every emulateNetworkConditions call fails, indicating a protocol/version mismatch
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame_session.go:1193 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/753dc3d384f6aa6f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame_session.go:1251
func (fs *FrameSession) updateHTTPCredentials(initial bool) error {
fs.logger.Debugf("NewFrameSession:updateHttpCredentials", "sid:%v tid:%v", fs.session.ID(), fs.targetID)
credentials := fs.page.browserCtx.opts.HTTPCredentials
if !initial || !credentials.IsEmpty() {
return fs.networkManager.Authenticate(credentials)
}
return nil
}
func (fs *FrameSession) updateOffline(initial bool) error {
fs.logger.Debugf("NewFrameSession:updateOffline", "sid:%v tid:%v", fs.session.ID(), fs.targetID)
offline := fs.page.browserCtx.opts.Offline
if !initial || offline {
if err := fs.networkManager.SetOfflineMode(offline); err != nil {
return fmt.Errorf("updating offline mode for frame %v: %w", fs.targetID, err)
}
}
return nil
}
func (fs *FrameSession) throttleNetwork(networkProfile NetworkProfile) error {
fs.logger.Debugf("NewFrameSession:throttleNetwork", "sid:%v tid:%v", fs.session.ID(), fs.targetID)
return fs.networkManager.ThrottleNetwork(networkProfile)
}
func (fs *FrameSession) throttleCPU(cpuProfile CPUProfile) error {
action := emulation.SetCPUThrottlingRate(cpuProfile.Rate)
if err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
return fmt.Errorf("throttling CPU: %w", err)
}
View on GitHub (pinned to 3fcf5388d7)