grafana/k6 · error
tests with unspecified duration are not allowed when…
Error message
tests with unspecified duration are not allowed when outputting data to k6 cloud
What it means
The cloud output must know when the test ends so it can close the cloud test run. lib.GetEndOffset walks the execution plan and reports whether a finite end exists; if no scenario yields a computable end time (testEnds=false), the output refuses to start with this error. This typically happens with open-ended executors such as externally-controlled scenarios without a bounded duration/endTime.
Solutions
- Give every scenario an explicit duration or endTime (e.g., duration: '10m' on constant-vus/arrival-rate executors, or endTime in startTime+duration terms)
- Replace open-ended executors with bounded ones (constant-arrival-rate with duration, per-vu-iterations with iterations) when pushing to the cloud
- If the test is intentionally open-ended (manual control), drop the cloud output and run locally or drive it via k6 cloud UI execution
Example fix
// before
export const options = {
scenarios: { ctrl: { executor: 'externally-controlled', vus: 2, maxVUs: 10 } },
};
// after
export const options = {
scenarios: { ctrl: { executor: 'externally-controlled', vus: 2, maxVUs: 10, duration: '10m' } },
}; Defensive patterns
Strategy: validation
Validate before calling
// k6 script: assert every scenario has a bounded end before relying on cloud output
function planIsBounded(scenarios) {
const bounded = ['constant-vus', 'ramping-vus', 'constant-arrival-rate', 'ramping-arrival-rate', 'shared-iterations', 'per-vu-iterations'];
return Object.values(scenarios).every((s) => bounded.includes(s.executor)
&& (s.duration != null || s.iterations != null || (Array.isArray(s.stages) && s.stages.length > 0)));
}
if (!planIsBounded(options.scenarios || {})) {
throw new Error('All scenarios need a finite duration/iterations for -o cloud');
} Prevention
- Give externally-controlled scenarios an explicit duration or endTime when targeting the cloud
- Smoke-test the exact options object with -o cloud before scheduling the real run
- Treat 'no computable end' as a design smell for cloud runs — cloud tests must end
When it happens
Trigger: k6 run -o cloud with a scenarios entry using executor 'externally-controlled' without a finite duration; an execution plan where the maximum end offset cannot be computed (no scenario defines duration/endTime/vUs-with-iterations bounds).
Common situations: Migrating a local test that ran fine without explicit durations to -o cloud; using externally-controlled scenarios intended for cloud execution but leaving timing unbounded; mixing stdin scripts with default options.
Related errors
- access token not configured
- both K6_CLOUD_METRICS_PUSH_URL and K6_CLOUD_TEST_RUN_TOKEN…
- no project specified. Use --project-id, set…
- script name not set, please specify K6_CLOUD_NAME or…
- stack ID not configured
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/05f3ab00af4e25ac.
Report an issue: GitHub.
Appendix: 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 8d06114777)