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
- Retry once after letting the page settle (waitForLoadState or locator.waitFor).
- Ensure no navigation is triggered concurrently with the check.
- Enable K6_DEBUG=true to correlate the race with navigation events.
- 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
- Don't fire state checks while navigation or iframe replacement is in progress.
- Stabilize with waitForLoadState before asserting.
- Collect K6_DEBUG logs for flaky cases and report stable repros to grafana/k6.
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
- ${name} constructor must be called with new
- failed to authenticate with k6 Cloud
- Error while parsing selector `${selector}` - selector cannot
- "level" attribute must be compared to a number
- "name" attribute must be a string or a regular expression
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/2025c66c4cd20f3c.
Report an issue: GitHub.