grafana/k6 · error
tests with unspecified duration are not allowed when outputt
Error message
tests with unspecified duration are not allowed when outputting data to k6 cloud
What it means
Raised while creating the cloud output when lib.GetEndOffset reports that the computed execution plan never ends. The k6 Cloud service must know when a test finishes, so with `--out cloud` every scenario needs a bounded duration or end time.
Source
Thrown at internal/cmd/outputs_cloud.go:88
thresholds := make(map[string][]string)
for name, t := range test.derivedConfig.Thresholds {
for _, threshold := range t.Thresholds {
thresholds[name] = append(thresholds[name], threshold.Source)
}
}
et, err := lib.NewExecutionTuple(
test.derivedConfig.ExecutionSegment,
test.derivedConfig.ExecutionSegmentSequence,
)
if err != nil {
return err
}
executionPlan := test.derivedConfig.Scenarios.GetFullExecutionRequirements(et)
duration, testEnds := lib.GetEndOffset(executionPlan)
if !testEnds {
return errors.New("tests with unspecified duration are not allowed when outputting data to k6 cloud")
}
if conf.MetricPushConcurrency.Int64 < 1 {
return fmt.Errorf("metrics push concurrency must be a positive number but is %d",
conf.MetricPushConcurrency.Int64)
}
if conf.MaxTimeSeriesInBatch.Int64 < 1 {
return fmt.Errorf("max allowed number of time series in a single batch must be a positive number but is %d",
conf.MaxTimeSeriesInBatch.Int64)
}
if conf.PushRefID.Valid && conf.PushRefID.String != "" {
if err := applyExternalProvisioningCreds(gs, test, &conf); err != nil {
return err
}
test.preInitState.RuntimeOptions.Env[testRunIDKey] = conf.PushRefID.String
gs.Logger.Debug("using PushRefID, skipping CreateTestRun")View on GitHub (pinned to 93accf6570)
Solutions
- Give every scenario an explicit duration, e.g. `{ executor: 'constant-vus', vus: 10, duration: '5m' }`
- Or use executors that end on their own budget: arrival-rate with `duration`, shared-iterations/per-vu-iterations with `iterations`
- If an open-ended test is intentional, drop `--out cloud` and stream metrics via `--out experimental-prometheus-rw` or another output instead
Example fix
// before
export const options = { vus: 10 };
// after
export const options = {
scenarios: { smoke: { executor: 'constant-vus', vus: 10, duration: '5m' } },
}; Defensive patterns
Strategy: validation
Validate before calling
// Verify before `k6 cloud` that every scenario is time-bounded
function assertBoundedScenarios(options) {
const s = options?.scenarios ?? { default: options };
for (const [name, sc] of Object.entries(s)) {
const bounded = sc.duration || sc.startTime || ['shared-iterations', 'per-vu-iterations'].includes(sc.executor);
if (!bounded) throw new Error(`scenario '${name}' has unspecified duration; cloud output requires it`);
}
}
assertBoundedScenarios(options); Prevention
- Always give scenarios an explicit `duration` (or endTime) when cloud output may be used
- Smoke-test `k6 inspect script.js` locally before `k6 cloud` to see the computed execution plan
- Keep a CI lint that rejects options files where an executor lacks duration/iterations
When it happens
Trigger: `k6 run --out cloud` (or `k6 cloud`) with an executor whose duration is unspecified, e.g. `constant-vus`/`ramping-vus` stages without `duration`, or an options set whose overall plan leaves `testEnds` false.
Common situations: Reusing locally-tuned options (open-ended scenarios, only `vus` set) with the cloud output; refactors that removed `duration` from a scenario; CLI overrides like `--vus 10` without `--duration` while cloud output is enabled.
Related errors
- tests with unspecified duration are not allowed when outputt
- scenario name can't be empty
- executor %s: function '%s' not found in exports
- error for stage %d: %w
- received empty projects page with next link
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/eb318e69a4a3bf91.
Report an issue: GitHub.