grafana/k6 · error
navigating to history entry
Error message
navigating to history entry %d: %w
What it means
Returned by Page history navigation (goBack/goForward) when the CDP Page.navigateToHistoryEntry call for the computed entry fails. The wrap names the target history index; the wrapped CDP error carries the cause — usually the entry being stale after a new navigation or the target closing.
Solutions
- Retry goBack/goForward after pending navigations complete
- Re-read the history stack before navigating if entries may have changed
- Ensure the page is not closing
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/page.go:1648 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/bd266b0e516cb2c3.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/page.go:1653
return nil, err
}
targetIndex := currentIndex + int64(delta)
// Check boundaries
if targetIndex < 0 || targetIndex >= int64(len(entries)) {
return nil, nil //nolint:nilnil
}
historyEntryID := entries[targetIndex].ID
targetURL := entries[targetIndex].URL
timeoutCtx, timeoutCancelFn := context.WithTimeout(p.ctx, opts.Timeout)
defer timeoutCancelFn()
navAction := page.NavigateToHistoryEntry(historyEntryID)
if err := navAction.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil {
return nil, fmt.Errorf("navigating to history entry %d: %w", historyEntryID, err)
}
wrapTimeoutError := func(err error) error {
if errors.Is(err, context.DeadlineExceeded) {
err = &k6ext.UserFriendlyError{
Err: err,
Timeout: opts.Timeout,
}
}
p.logger.Debugf("Page:GoBackForward", "timeoutCtx done: %v", err)
return fmt.Errorf("navigating %s to history entry %d: %w", direction, historyEntryID, err)
}
// Poll for URL change, don't rely on lifecycle events since bfcache
// restorations don't re-fire them.
ticker := time.NewTicker(50 * time.Millisecond)
defer ticker.Stop()
View on GitHub (pinned to 3fcf5388d7)