grafana/k6 · error
attaching iframe target ID
Error message
attaching iframe target ID %v to session ID %v: %w
What it means
While handling Target.attachedToTarget for an iframe, constructing the nested NewFrameSession for the iframe's target failed. The wrapped error carries the setup failure (CDP error during frame init); the attach is aborted and the iframe cannot be automated.
Solutions
- Inspect the wrapped error for the frame-session setup failure
- Check the iframe's page for crashes or unsupported features
- Update k6/Chromium and retry; transient attach failures occur
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame_session.go:1054 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/b9c8638708710fb9.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame_session.go:1112
return nil
}
// Remove all children of the previously attached frame.
err := fs.manager.removeChildFramesRecursively(fr)
if err != nil {
fs.logger.Debugf("FrameSession:attachIFrameToTarget:return",
"sid:%v tid:%v esid:%v etid:%v ebctxid:%v type:%q, can't remove child frames recursively: %q",
fs.session.ID(), fs.targetID, sid, ti.TargetID, ti.BrowserContextID, ti.Type, err)
}
nfs, err := NewFrameSession(
fs.ctx,
fs.teardownCtx,
session,
fs.page, fs, ti.TargetID,
fs.logger,
false)
if err != nil {
return fmt.Errorf("attaching iframe target ID %v to session ID %v: %w",
ti.TargetID, sid, err)
}
if err := fs.page.attachFrameSession(cdp.FrameID(ti.TargetID), nfs); err != nil {
if errors.Is(err, errPageClosing) {
fs.logger.Debugf("FrameSession:attachIFrameToTarget",
"rejected frame; page is closing: tid=%v", ti.TargetID)
detachSession(session)
return nil
}
return err
}
return nil
}
// attachWorkerToTarget attaches a Worker target to a given session.
func (fs *FrameSession) attachWorkerToTarget(ti *target.Info, session *Session) error {View on GitHub (pinned to 3fcf5388d7)