grafana/k6 · error

fail to fulfill request

Error message

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

What it means

Failure of the CDP Fetch.fulfillRequest command while serving a mocked response (with optional headers and base64 body) for the identified request. Context-canceled failures during teardown are swallowed; other causes are typically the request already being done or the target navigating away.

Solutions

  1. Fulfill intercepted requests promptly in the route handler
  2. Ensure response body/status provided are valid and the request is still paused
  3. Ignore failures that coincide with page navigation or iteration end
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/network_manager.go:1013 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/0cb54d7d86364443. Report an issue: GitHub.

Appendix: source

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

	if len(headers) > 0 {
		action = action.WithResponseHeaders(headers)
	}

	if len(opts.Body) > 0 {
		b64Body := base64.StdEncoding.EncodeToString(opts.Body)
		action = action.WithBody(b64Body)
	}

	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:FulfillRequest", "context canceled fulfilling request")
			return nil
		}

		return fmt.Errorf("fail to fulfill request (id: %s): %w",
			request.interceptionID, err)
	}

	return nil
}

func toFetchHeaders(headers []HTTPHeader) []*fetch.HeaderEntry {
	if len(headers) == 0 {
		return nil
	}

	fetchHeaders := make([]*fetch.HeaderEntry, len(headers))
	for i, header := range headers {
		fetchHeaders[i] = &fetch.HeaderEntry{
			Name:  header.Name,
			Value: header.Value,
		}
	}

View on GitHub (pinned to 8d06114777)