grafana/k6 · critical
internal error while getting browser target info
Error message
internal error while getting browser target info: %w
What it means
Right after setAutoAttach, connect() issues a dummy Target.getTargetInfo call to work around a Chromium bug where setAutoAttach does not wait for pending target attachments (see the chromium-review link in the source). This error wraps that follow-up CDP call failing, i.e. the connection or browser died within milliseconds of the previous command, or the endpoint partially implements CDP.
Solutions
- Check whether the browser process was killed (dmesg OOM lines, container exit code 137) and raise memory limits
- Stabilize the remote endpoint / proxy between k6 and the browser
- Match Chromium or headless-shell version to the k6 release notes
- Capture K6_BROWSER_LOG=debug output and report if it persists on stock versions
Defensive patterns
Strategy: retry
Try / catch
try {
const browser = chromium.launch();
} catch (e) {
if (String(e).includes('getting browser target info')) {
// connection dropped right after connect; check for OOM-killed browser
// (exit 137, dmesg), stabilize environment, retry once
}
} Prevention
- Watch for OOM kills on browser containers during startup
- Give the browser a few seconds of warm-up before heavy load
- Use stable network paths to remote browsers
When it happens
Trigger: Connection loss between setAutoAttach and GetTargetInfo; browser process killed (OOM, SIGKILL from CI timeouts) moments after startup; a CDP proxy dropping frames; protocol-level mismatch with an unsupported browser build.
Common situations: CI jobs killing the browser with strict timeouts; memory-constrained runners; flaky WS proxies in remote-browser setups.
Related errors
- internal error while auto-attaching to browser pages
- getting browser version information
- adding init script to browser context
- browser not found in registry. make sure to set browser…
- can't fetch the page for unknown reason
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/bc8f7c0a774c2bc5.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/browser.go:260
} else if event.typ == EventConnectionClose {
b.logger.Debugf("Browser:initEvents:EventConnectionClose", "")
return
}
}
}
}()
action := target.SetAutoAttach(true, true).WithFlatten(true)
if err := action.Do(cdp.WithExecutor(b.vuCtx, b.conn)); err != nil {
return fmt.Errorf("internal error while auto-attaching to browser pages: %w", err)
}
// Target.setAutoAttach has a bug where it does not wait for new Targets being attached.
// However making a dummy call afterwards fixes this.
// This can be removed after https://chromium-review.googlesource.com/c/chromium/src/+/2885888 lands in stable.
action2 := target.GetTargetInfo()
if _, err := action2.Do(cdp.WithExecutor(b.vuCtx, b.conn)); err != nil {
return fmt.Errorf("internal error while getting browser target info: %w", err)
}
return nil
}
// connectionOnAttachedToTarget is called when Connection receives an attachedToTarget
// event. Returning false makes the connection release the target instead of
// adopting it. Targets from the connection's own browser context and from
// the default browser context are accepted.
func (b *Browser) connectionOnAttachedToTarget(eva *target.EventAttachedToTarget) bool {
b.contextMu.RLock()
defer b.contextMu.RUnlock()
if b.context != nil && b.context.id == eva.TargetInfo.BrowserContextID {
return true
}
return b.defaultContext.id == eva.TargetInfo.BrowserContextID
}
View on GitHub (pinned to 3fcf5388d7)