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
Thrown by the cloud output's constructor when the calculated execution plan has no determinable end time. Before opening a cloud output, k6 calls lib.GetEndOffset(params.ExecutionPlan); if it reports that the test never ends (testEnds == false), the cloud output refuses to start because the k6 Cloud service requires a bounded test duration to provision and finalize a test run.
Source
Thrown at internal/output/cloud/output.go:178
logger := params.Logger.WithFields(logrus.Fields{"output": "cloud"})
if !conf.Name.Valid || conf.Name.String == "" {
scriptPath := params.ScriptPath.String()
if scriptPath == "" {
// Script from stdin without a name, likely from stdin
return nil, errors.New("script name not set, please specify K6_CLOUD_NAME or options.cloud.name")
}
conf.Name = null.StringFrom(filepath.Base(scriptPath))
}
if conf.Name.String == "-" {
conf.Name = null.StringFrom(defaultTestName)
}
duration, testEnds := lib.GetEndOffset(params.ExecutionPlan)
if !testEnds {
return nil, errors.New("tests with unspecified duration are not allowed when outputting data to k6 cloud")
}
if conf.MetricPushConcurrency.Int64 < 1 {
return nil, fmt.Errorf("metrics push concurrency must be a positive number but is %d",
conf.MetricPushConcurrency.Int64)
}
if conf.MaxTimeSeriesInBatch.Int64 < 1 {
return nil, fmt.Errorf("max allowed number of time series in a single batch must be a positive number but is %d",
conf.MaxTimeSeriesInBatch.Int64)
}
apiClient := cloudapi.NewClient(
logger, conf.Token.String, conf.Host.String, build.Version, conf.Timeout.TimeDuration())
return &Output{
config: conf,
client: apiClient,View on GitHub (pinned to 93accf6570)
Solutions
- Add a bounded duration to the script: export const options = { vus: 10, duration: '30s' } or give every scenario an explicit duration/endTime
- If using execution scenarios, ensure each executor produces a known end (e.g. constant-vus with duration, per-vu-iterations with iterations set)
- If the test is intentionally open-ended, drop the cloud output and use a local output (-o json, -o csv, -o prometheus-rw) instead
- Check options merging: a CLI flag like --duration 0 or --vus without --duration may have overridden the script's duration
Example fix
// before
export const options = { vus: 10, iterations: 1000 }; // no duration, never 'ends' for cloud
// after
export const options = { vus: 10, duration: '2m' }; Defensive patterns
Strategy: validation
Validate before calling
# Before enabling the cloud output, confirm the plan has a finite end:
k6 inspect --execution 'script.js' | jq '[.scenarios[] | has("endTime") or has("duration")] | all'
# Or in Go, before constructing the output:
// _, testEnds := lib.GetEndOffset(executionPlan); if !testEnds { /* refuse */ } Prevention
- Always export a duration (or bounded executors) in options when cloud output is enabled
- Add a CI preflight step: k6 inspect script.js and fail if no scenario reports an end time
- Treat 'vus without duration' as a lint error in script review
When it happens
Trigger: Any configuration that activates the cloud output (k6 cloud run --local-execution, -o cloud, or options.cloud) combined with an open-ended execution plan: a script using only 'vus'/'iterations' style options without a duration (e.g. exported handleSummary-style scripts run with vus:1, iterations:0), a scenario with an executor that has no endTime/duration (e.g. manual or shared-iterations without iteration limits, or a constant-vus scenario with duration: 0 / unset), or a plan whose max end offset cannot be computed.
Common situations: Migrating an old script that relied on externally stopped runs (k6 pause/scale workflows) to cloud output; setting options.vus and options.iterations but forgetting options.duration when also enabling -o cloud; CI scripts that assume indefinite runs stopped by timeout; using execution: { scenarios: { s: { executor: 'constant-vus', vus: 1 } } } with no duration field.
Related errors
- both K6_CLOUD_METRICS_PUSH_URL and K6_CLOUD_TEST_RUN_TOKEN m
- v1 is not supported anymore
- cloud secrets not configured: no secrets configuration avail
- tests with unspecified duration are not allowed when outputt
- influxdb's ConcurrentWrites must be a positive number
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/05f3ab00af4e25ac.
Report an issue: GitHub.