{"record":{"id":"b5919b3ef512a4ac","repo":"grafana/k6","slug":"wait-for-test-run-ready-w","errorCode":null,"errorMessage":"wait for test run ready: %w","messagePattern":"wait for test run ready: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/provision.go","lineNumber":102,"sourceCode":"\n\tsleResp, err := c.StartLocalExecution(ctx, loadTestID, sleReq)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"start local execution: %w\", err)\n\t}\n\n\tswitch {\n\tcase params.Archive != nil && sleResp.ArchiveUploadURL != nil:\n\t\tif err := c.UploadArchive(ctx, *sleResp.ArchiveUploadURL, archiveBytes); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"upload archive: %w\", err)\n\t\t}\n\tcase params.Archive != nil && sleResp.ArchiveUploadURL == nil:\n\t\t// We had an archive to upload but the API returned no upload URL;\n\t\t// proceed without uploading rather than failing the run.\n\t\tc.logger.Warn(\"archive present but provisioning API returned no upload URL; skipping archive upload\")\n\t}\n\n\tif err := c.WaitForTestRunReady(ctx, sleResp.TestRunID, params.PollInterval); err != nil {\n\t\treturn nil, fmt.Errorf(\"wait for test run ready: %w\", err)\n\t}\n\n\treturn &ProvisionResult{\n\t\tTestRunID:             sleResp.TestRunID,\n\t\tTestRunDetailsPageURL: sleResp.TestRunDetailsPageURL,\n\t\tRuntimeConfig:         sleResp.RuntimeConfig,\n\t}, nil\n}\n","sourceCodeStart":84,"sourceCodeEnd":111,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/provisioning/provision.go#L84-L111","documentation":"Client.ProvisionLocalExecution (internal/cloudapi/provisioning/provision.go:102) wraps the failure of Client.WaitForTestRunReady — the run never reached 'initializing'. The wrapped error distinguishes the causes: 'test run aborted before starting: <msg>' (backend aborted it, message included), 'test run completed before k6 could start', 'fetching test status: ...' (poll API failing), or context.Canceled/DeadlineExceeded if the caller gave up.","triggerScenarios":"Backend aborts the run before start (org concurrency limit, quota, maintenance); the caller's context is cancelled (Ctrl+C during provisioning); the v6 test-runs polling endpoint repeatedly failing; run completing before this k6 attached.","commonSituations":"Org hit its concurrent cloud test limit; user interrupted the run during the provisioning wait; backend incidents making the poll endpoint error; overly tight outer timeouts around provisioning.","solutions":["Read the wrapped message — abort messages from the backend state the exact limit/reason","Address the limit/quota named in the abort message, then re-run","If context.Canceled, widen the outer timeout or avoid cancelling during provisioning","Give PollInterval room (default 2s) and rely on the context, not external kills, to bound the wait"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"provCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)\ndefer cancel()\nres, err := client.ProvisionLocalExecution(ctx2, provCtxParams) // pass provCtx","typeGuard":"func abortReason(err error) string {\n\tif m := regexp.MustCompile(`test run aborted before starting: (.+)`); m.MatchString(err.Error()) {\n\t\treturn m.FindStringSubmatch(err.Error())[1]\n\t}\n\treturn \"\"\n}","tryCatchPattern":"res, err := client.ProvisionLocalExecution(ctx, params)\nif err != nil {\n\tif reason := abortReason(err); reason != \"\" {\n\t\t// backend refused the run: fix the named limit/quota before re-running\n\t}\n\tif errors.Is(err, context.Canceled) {\n\t\t// user or outer timeout cancelled during the ready-wait\n\t}\n\treturn err\n}","preventionTips":["Give provisioning a generous, explicit context timeout","Watch org concurrency/quota limits before starting runs","Surface backend abort messages verbatim — they name the actionable cause","Avoid cancelling the run during the provisioning window"],"tags":["cloud-api","provisioning","polling","abort","context"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}