{"record":{"id":"bd266b0e516cb2c3","repo":"grafana/k6","slug":"navigating-to-history-entry-d-w","errorCode":null,"errorMessage":"navigating to history entry %d: %w","messagePattern":"navigating to history entry (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":1653,"sourceCode":"\t\treturn nil, err\n\t}\n\n\ttargetIndex := currentIndex + int64(delta)\n\n\t// Check boundaries\n\tif targetIndex < 0 || targetIndex >= int64(len(entries)) {\n\t\treturn nil, nil //nolint:nilnil\n\t}\n\n\thistoryEntryID := entries[targetIndex].ID\n\ttargetURL := entries[targetIndex].URL\n\n\ttimeoutCtx, timeoutCancelFn := context.WithTimeout(p.ctx, opts.Timeout)\n\tdefer timeoutCancelFn()\n\n\tnavAction := page.NavigateToHistoryEntry(historyEntryID)\n\tif err := navAction.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil {\n\t\treturn nil, fmt.Errorf(\"navigating to history entry %d: %w\", historyEntryID, err)\n\t}\n\n\twrapTimeoutError := func(err error) error {\n\t\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t\terr = &k6ext.UserFriendlyError{\n\t\t\t\tErr:     err,\n\t\t\t\tTimeout: opts.Timeout,\n\t\t\t}\n\t\t}\n\t\tp.logger.Debugf(\"Page:GoBackForward\", \"timeoutCtx done: %v\", err)\n\t\treturn fmt.Errorf(\"navigating %s to history entry %d: %w\", direction, historyEntryID, err)\n\t}\n\n\t// Poll for URL change, don't rely on lifecycle events since bfcache\n\t// restorations don't re-fire them.\n\tticker := time.NewTicker(50 * time.Millisecond)\n\tdefer ticker.Stop()\n","sourceCodeStart":1635,"sourceCodeEnd":1671,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L1635-L1671","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:1648 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}