grafana/k6 · error
fetching test status: %w
Error message
fetching test status: %w
What it means
WaitForTestRunReady (internal/cloudapi/provisioning/api.go:130-148) polls the cloud API (v6Client.FetchTest) every couple of seconds until the provisioned test run reaches 'initializing'. Any failed poll - transport error, 401/403, 404, or exhausted retries - aborts the wait wrapped as 'fetching test status'. k6 never got far enough to start executing; the wrapped error says why the polling died.
Source
Thrown at internal/cloudapi/provisioning/api.go:144
// WaitForTestRunReady polls GET /cloud/v6/test_runs/{id} until the
// backend status becomes "initializing" (signalling that k6 can begin
// local execution). Returns an error if the test run reaches "aborted"
// or "completed" first. Cancellable via context. Logs status transitions
// at Debug level once per change.
//
// If pollInterval is <= 0 the defaultWaitPollInterval is used.
func (c *Client) WaitForTestRunReady(ctx context.Context, testRunID int64, pollInterval time.Duration) error {
if pollInterval <= 0 {
pollInterval = defaultWaitPollInterval
}
var lastStatus string
for {
progress, err := c.v6Client.FetchTest(ctx, testRunID)
if err != nil {
return fmt.Errorf("fetching test status: %w", err)
}
status := progress.Status.String()
switch v6.Status(status) {
case v6.StatusInitializing:
return nil
case v6.StatusAborted:
var abortMsg string
for _, e := range progress.StatusHistory {
if e.Status == v6.StatusAborted && e.Message != "" {
abortMsg = e.Message
break
}
}
if abortMsg != "" {
return fmt.Errorf("test run aborted before starting: %s", abortMsg)View on GitHub (pinned to 93accf6570)
Solutions
- Read the wrapped error for an HTTP status: 401/403 -> fix the cloud token; 404 -> the run was deleted; 5xx/network -> retry the whole run
- Re-run the test - a fresh provisioning gets a fresh run ID and polling loop
- Check the Grafana Cloud status page if 5xx persists
- Avoid deleting/recreating cloud test runs between start_local_execution and execution start
Defensive patterns
Strategy: retry
Try / catch
if err := client.WaitForTestRunReady(ctx, id, 0); err != nil {
if strings.Contains(err.Error(), "fetching test status") {
// poll failed mid-wait: safe to retry the whole run; a fresh provisioning
// gets a new run ID - but first read the wrapped error for 401/403/404
}
} Prevention
- Do not delete or recreate cloud test runs between provisioning and execution start
- Keep cloud tokens valid for the full run lifecycle including the wait window
- Treat repeated 'fetching test status' failures as a cloud API availability signal - check the status page
When it happens
Trigger: Transient network failure or cloud API 5xx during the pre-start polling window; the test run being deleted (404) or the token revoked (401/403) while k6 waits; a backend outage that outlasts the client's retry budget.
Common situations: Someone deletes or reconfigures the cloud test run right after provisioning; cloud API blips; expired credentials on long-queued runs.
Related errors
- unexpected HTTP error from %s: %d %s
- archive upload failed: %d %s
- archive upload failed: %d %s: %s
- 98
- missing presigned url in response body
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/26211ddb113868f4.
Report an issue: GitHub.