grafana/k6 · error

an error occurred communicating with the provisioning API

Error message

an error occurred communicating with the provisioning API

What it means

After the isDisabled action succeeds (frame.go:1512), k6 asserts the result is a bool and returns 'checking is %q disabled: unexpected type %T' when it is not. Since waitForElementState returns a Go bool, a non-bool (usually nil) means the action machinery returned an unexpected value: a race with frame detachment/navigation, or a bug in the k6 browser module's value handling. Like the other 'unexpected type' state checks, it is an internal invariant break rather than an application state.

Source

Thrown at internal/cloudapi/provisioning/errors.go:12

package provisioning

import (
	"errors"
	"fmt"
	"io"
	"net/http"

	"go.k6.io/k6/v2/internal/cloudapi/httperr"
)

var errUnknown = errors.New("an error occurred communicating with the provisioning API")

// ResponseError represents an error returned by the provisioning API.
type ResponseError struct {
	StatusCode int
	Body       string
}

func (e *ResponseError) Error() string {
	return fmt.Sprintf("provisioning API error (%d): %s", e.StatusCode, e.Body)
}

// CheckResponse checks an HTTP response from the provisioning API.
// It returns nil if the status code is in the 2xx range, otherwise it
// returns a *ResponseError with the status code and response body.
func CheckResponse(resp *http.Response) error {
	if resp == nil {
		return errUnknown
	}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Retry once after letting the page settle (waitForLoadState or locator.waitFor).
  2. Ensure no navigation is triggered concurrently with the check.
  3. Enable K6_DEBUG=true to correlate the race with navigation events.
  4. File a grafana/k6 issue with a reproducible script if it persists.

Example fix

// before
const off = await page.isDisabled('#submit');

// after
await page.waitForLoadState('domcontentloaded');
let off;
try { off = await page.isDisabled('#submit'); }
catch (e) {
  if (!String(e).includes('unexpected type')) throw e;
  off = await page.isDisabled('#submit'); // single retry
}
Defensive patterns

Strategy: retry

Validate before calling

await page.waitForLoadState('domcontentloaded');

Try / catch

try {
  return await page.isDisabled(sel);
} catch (e) {
  if (!String(e).includes('unexpected type')) throw e;
  await page.waitForLoadState('domcontentloaded');
  return await page.isDisabled(sel); // retry once past the race
}

Prevention

When it happens

Trigger: Frame detaches or navigates between selector resolution and result delivery; nil value on a rare error path; CDP session teardown races; browser-module regression.

Common situations: Intermittent CI failures during page transitions; SPA iframe swaps racing the check; first appearances after a k6 upgrade.

Related errors


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/2025c66c4cd20f3c. Report an issue: GitHub.