grafana/k6 · error
internal error while removing binding from page
Error message
internal error while removing binding from page: %w
What it means
Failure of the CDP runtime.removeBinding command during page close while removing the web-vitals binding. Deliberately non-fatal: the error is appended to closeErrs and shutdown continues, because teardown must proceed even if the binding cannot be removed.
Solutions
- Treat as non-fatal — page close proceeds regardless
- Occurs mostly when the target is already gone; no action needed
- Report only if it accompanies other consistent close failures
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/page.go:1007 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/e900b0e74a00b938.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/page.go:1012
Object.defineProperty(document, 'visibilityState', {value: 'hidden', configurable: true});
Object.defineProperty(document, 'hidden', {value: true, configurable: true});
document.dispatchEvent(new Event('visibilitychange'));
}`
if _, err := p.MainFrame().EvaluateWithContext(teardownTimeoutCtx, v); err != nil {
p.logger.Warnf("Page:Close", "failed to trigger visibilitychange for web vitals: %v", err)
}
keyDown := input.DispatchKeyEvent(input.KeyDown).WithKey("Escape")
if err := keyDown.Do(cdp.WithExecutor(teardownTimeoutCtx, p.session)); err != nil {
p.logger.Warnf("Page:Close", "failed to dispatch keydown for web vitals: %v", err)
}
var closeErrs []error
add := runtime.RemoveBinding(webVitalBinding)
if err := add.Do(cdp.WithExecutor(teardownTimeoutCtx, p.session)); err != nil {
// continue so that we can shutdown the page even if we fail to remove the binding.
closeErrs = append(closeErrs, fmt.Errorf("internal error while removing binding from page: %w", err))
}
err := target.CloseTarget(p.targetID).Do(cdp.WithExecutor(teardownTimeoutCtx, p.session))
if err != nil && !errors.Is(err, context.Canceled) {
// When a close target command is sent to the browser via CDP,
// the browser will start to cleanup and the first thing it
// will do is return a target.EventDetachedFromTarget, which in
// our implementation will close the session connection (this
// does not close the CDP websocket, just removes the session
// so no other CDP calls can be made with the session ID).
// This can result in the session's context being closed while
// we're waiting for the response to come back from the browser
// for this current command (it's racey).
closeErrs = append(closeErrs, fmt.Errorf("closing a page: %w", err))
}
// Start the teardown of the page's resources (FrameSessions, NetworkManagers, etc)
// and wait for them to finish their teardown. This allows for a graceful cleanupView on GitHub (pinned to 3fcf5388d7)