grafana/k6 · error

fail to abort request

Error message

fail to abort request (id: %s): %w

What it means

Failure of the CDP Fetch.failRequest command while aborting the identified intercepted request. Fires when the session rejects the command — commonly because the request already completed, the target navigated away, or the context was canceled during teardown (which is deliberately not logged as an error).

Solutions

  1. Abort requests promptly in the route handler before they complete
  2. Ignore context-canceled failures during iteration teardown
  3. Check the request ID is still intercepted (Fetch domain active) when aborting
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/network_manager.go:925 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/3799a2da74e41148. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/network_manager.go:925

}

func (m *NetworkManager) AbortRequest(requestID fetch.RequestID, errorReason string) error {
	m.logger.Debugf("NetworkManager:AbortRequest", "aborting request (id: %s, errorReason: %s)",
		requestID, errorReason)
	netErrorReason, ok := m.errorReasons[errorReason]
	if !ok {
		return fmt.Errorf("unknown error code: %s", errorReason)
	}

	action := fetch.FailRequest(requestID, netErrorReason)
	if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
		// Avoid logging as error when context is canceled.
		// Most probably this happens when trying to fail a site's background request
		// while the iteration is ending and therefore the browser context is being closed.
		if errors.Is(err, context.Canceled) {
			m.logger.Debug("NetworkManager:AbortRequest", "context canceled interrupting request")
		} else {
			return fmt.Errorf("fail to abort request (id: %s): %w", requestID, err)
		}
	}

	return nil
}

func (m *NetworkManager) ContinueRequest(
	requestID fetch.RequestID,
	opts ContinueOptions,
	originalHeaders []HTTPHeader,
) error {
	m.logger.Debugf("NetworkManager:ContinueRequest", "continuing request (id: %s)", requestID)
	action := fetch.ContinueRequest(requestID)

	if len(opts.Headers) > 0 {
		action = action.WithHeaders(toFetchHeaders(opts.Headers))
	}
	if opts.URL != "" {

View on GitHub (pinned to 8d06114777)