{"record":{"id":"0724544c67f3a748","repo":"grafana/k6","slug":"setuptimeout-must-be-positive","errorCode":null,"errorMessage":"setupTimeout must be positive","messagePattern":"setupTimeout must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/options.go","lineNumber":548,"sourceCode":"\t// TODO: validate all of the other options... that we should have already been validating...\n\t// TODO: maybe integrate an external validation lib: https://github.com/avelino/awesome-go#validation\n\tvar validationErrors []error\n\tif o.ExecutionSegmentSequence != nil {\n\t\tvar segmentFound bool\n\t\tif slices.ContainsFunc(*o.ExecutionSegmentSequence, o.ExecutionSegment.Equal) {\n\t\t\tsegmentFound = true\n\t\t}\n\t\tif !segmentFound {\n\t\t\tvalidationErrors = append(validationErrors,\n\t\t\t\tfmt.Errorf(\"provided segment %s can't be found in sequence %s\",\n\t\t\t\t\to.ExecutionSegment, o.ExecutionSegmentSequence))\n\t\t}\n\t}\n\tvalidationErrors = append(validationErrors, o.Scenarios.Validate()...)\n\n\t// Duration\n\tif o.SetupTimeout.Valid && o.SetupTimeout.Duration <= 0 {\n\t\tvalidationErrors = append(validationErrors, errors.New(\"setupTimeout must be positive\"))\n\t}\n\treturn validationErrors\n}\n\n// ForEachSpecified enumerates all struct fields and calls the supplied function with each\n// element that is valid. It panics for any unfamiliar or unexpected fields, so make sure\n// new fields in Options are accounted for.\nfunc (o Options) ForEachSpecified(structTag string, callback func(key string, value any)) {\n\tstructType := reflect.TypeFor[Options]()\n\tstructVal := reflect.ValueOf(o)\n\tfor i := 0; i < structType.NumField(); i++ {\n\t\tfieldType := structType.Field(i)\n\t\tfieldVal := structVal.Field(i)\n\t\tvalue := fieldVal.Interface()\n\n\t\tvar shouldCall bool\n\t\tswitch fieldType.Type.Kind() {\n\t\tcase reflect.Struct:","sourceCodeStart":530,"sourceCodeEnd":566,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/lib/options.go#L530-L566","documentation":"Emitted by Options.Validate (lib/options.go:547-549) when setupTimeout is explicitly specified but not strictly positive (<= 0). setupTimeout bounds how long the exported setup() function may run before the test is aborted. Only a specified (Valid) value is checked — omitting the option keeps the default (60s). Zero or negative timeouts are rejected because they would abort setup before it can execute.","triggerScenarios":"Exporting options = { setupTimeout: '0s' } or { setupTimeout: '-5s' }; also when CLI flag --setup-timeout 0s or env K6_SETUP_TIMEOUT=0s is set. Validation runs during option consolidation before the test starts.","commonSituations":"Users trying to disable the setup timeout by setting it to zero (not supported — use a large value like '1h' instead); CI pipelines templating timeout values that resolve empty/zero; sign typos in generated configs.","solutions":["Remove the setupTimeout option to use the default of 60s","Or set a positive duration large enough for setup work, e.g. setupTimeout: '5m'; to effectively disable it use a very large value such as '1h'"],"exampleFix":"// before\nexport const options = { setupTimeout: '0s' };\n\n// after\nexport const options = { setupTimeout: '5m' };","handlingStrategy":"validation","validationCode":"// JS: reject non-positive timeouts in generated options\nfunction timeout(v, fallback) {\n  if (!v) return fallback;\n  const m = /^([0-9]+(?:\\.[0-9]+)?)(ms|s|m|h)$/.exec(v);\n  if (!m || parseFloat(m[1]) <= 0) throw new Error(`invalid timeout: ${v}`);\n  return v;\n}\nexport const options = { setupTimeout: timeout(__ENV.SETUP_TIMEOUT, '60s') };","typeGuard":null,"tryCatchPattern":null,"preventionTips":["setupTimeout must be strictly positive; to 'disable' it use a large value like '1h', not 0","Apply the same rule to teardownTimeout and per-senario gracefulStop when templating configs"],"tags":["config","options","setuptimeout","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}