grafana/k6 · error

network cache

Error message

%s network cache: %w

What it means

Failure of the CDP Network.setCacheDisabled command when the cache state is being (de)activated in response to SetCacheEnabled. The verb in the message reflects the requested direction; the cause is a protocol-level failure (closed session/target or canceled context), not the boolean value itself.

Solutions

  1. Ensure the page and session are alive when toggling cache
  2. Call SetCacheEnabled before navigation begins rather than mid-teardown
  3. Inspect the wrapped CDP error for connection-level causes
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

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

	e, ok := m.reqIDToRequestPausedEvent[reqID]

	return e, ok
}

func (m *NetworkManager) setRequestInterception(value bool) error {
	m.userReqInterceptionEnabled = value
	return m.updateProtocolRequestInterception()
}

func (m *NetworkManager) updateProtocolCacheDisabled() error {
	action := network.SetCacheDisabled(m.userCacheDisabled)
	if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
		errAction := "enabling"
		if m.userCacheDisabled {
			errAction = "disabling"
		}
		return fmt.Errorf("%s network cache: %w", errAction, err)
	}
	return nil
}

func (m *NetworkManager) updateProtocolRequestInterception() error {
	enabled := m.userReqInterceptionEnabled
	if enabled == m.protocolReqInterceptionEnabled {
		return nil
	}

	m.protocolReqInterceptionEnabled = enabled
	m.logger.Debugf("NetworkManager:updateProtocolRequestInterception",
		"updating request interception to %t (session: %s)", enabled, m.session.ID())

	actions := []Action{
		network.SetCacheDisabled(true),
		fetch.Enable().
			WithHandleAuthRequests(true).

View on GitHub (pinned to 8d06114777)