grafana/k6 · error
run if waiting for debugger to attach
Error message
run if waiting for debugger to attach: %w
What it means
During NewFrameSession setup, running Browser.setPauseOnStart (the 'run if waiting for debugger to attach' CDP option) failed. The wrapped error comes from Chromium over CDP; setup of the frame session aborts, so the page/iframe target cannot be used.
Solutions
- Inspect the wrapped CDP error for Chromium's reason
- Update k6 and the bundled/used Chromium version — CDP protocol mismatches can cause this
- Retry the test; transient CDP failures during attach can occur under load
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame_session.go:129 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/2dc3fe45f8789b2f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame_session.go:158
session: s,
page: p,
parent: parent,
manager: p.frameManager,
targetID: tid,
contextIDToContextMu: sync.Mutex{},
contextIDToContext: make(map[cdpruntime.ExecutionContextID]*ExecutionContext),
isolatedWorlds: make(map[string]bool),
eventCh: make(chan Event),
childSessions: make(map[cdp.FrameID]*FrameSession),
bufferedWebVitals: make(map[webVitalKey]webVitalSample),
vu: k6ext.GetVU(ctx),
k6Metrics: k6Metrics,
logger: l,
hasUIWindow: hasUIWindow,
}
if err := cdpruntime.RunIfWaitingForDebugger().Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
return nil, fmt.Errorf("run if waiting for debugger to attach: %w", err)
}
var parentNM *NetworkManager
if fs.parent != nil {
parentNM = fs.parent.networkManager
}
fs.networkManager, err = NewNetworkManager(ctx, k6Metrics, s, fs.manager, parentNM, fs.manager.page)
if err != nil {
l.Debugf("NewFrameSession:NewNetworkManager", "sid:%v tid:%v err:%v",
s.ID(), tid, err)
return nil, err
}
// When a frame creates a new FrameSession without UI (e.g. some iframes) we cannot
// retrieve the windowID. Doing so would lead to an error from chromium. For now all
// iframes that are attached are setup with hasUIWindow as false which seems to work
// as expected for iframes with and without UI elements.
if fs.hasUIWindow {View on GitHub (pinned to 3fcf5388d7)