{"record":{"id":"3e152a0a29440df0","repo":"grafana/k6","slug":"error-while-initializing-executor-s-w","errorCode":null,"errorMessage":"error while initializing executor %s: %w","messagePattern":"error while initializing executor (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/execution/scheduler.go","lineNumber":317,"sourceCode":"\t\tinitErr = err\n\t\tcancel(initErr)\n\t}\n\n\tif initErr != nil {\n\t\treturn initErr\n\t}\n\n\te.state.SetInitVUFunc(func(ctx context.Context, logger *logrus.Entry) (lib.InitializedVU, error) {\n\t\treturn e.initVU(ctx, samplesOut, logger)\n\t})\n\n\te.state.SetExecutionStatus(lib.ExecutionStatusInitExecutors)\n\tlogger.Debugf(\"Finished initializing needed VUs, start initializing executors...\")\n\tfor _, exec := range e.executors {\n\t\texecutorConfig := exec.GetConfig()\n\n\t\tif err := exec.Init(ctx); err != nil {\n\t\t\treturn fmt.Errorf(\"error while initializing executor %s: %w\", executorConfig.GetName(), err)\n\t\t}\n\t\tlogger.Debugf(\"Initialized executor %s\", executorConfig.GetName())\n\t}\n\n\te.state.SetExecutionStatus(lib.ExecutionStatusInitDone)\n\tlogger.Debugf(\"Initialization completed\")\n\treturn nil\n}\n\n// runExecutor gets called by the public Run() method once per configured\n// executor, each time in a new goroutine. It is responsible for waiting out the\n// configured startTime for the specific executor and then running its Run()\n// method.\nfunc (e *Scheduler) runExecutor(\n\trunCtx context.Context, runResults chan<- error, engineOut chan<- metrics.SampleContainer, executor lib.Executor,\n) {\n\texecutorConfig := executor.GetConfig()\n\texecutorStartTime := executorConfig.GetStartTime()","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/execution/scheduler.go#L299-L335","documentation":"The Scheduler is k6's top-level execution coordinator. After VU initialization it calls Init(ctx) on every configured executor (scenario); if any one fails, initialization aborts and this error wraps the scenario name plus the underlying cause. In practice Init fails inside lib/executor when an arrival-rate executor rebuilds its execution tuple from MaxVUs (GetNewExecutionTupleFromValue) and the execution segment/sequence setup is inconsistent. The error is fatal: the test never starts.","triggerScenarios":"k6 run with --execution-segment / --execution-segment-sequence flags that conflict (a segment the sequence cannot produce, or a segment sequence that does not partition 0..1); a scenario whose MaxVUs cannot be mapped by the configured segment; any extension executor whose Init returns an error. The %s is the key from options.scenarios.<name>.","commonSituations":"Distributed k6 runs using execution segment flags to shard load across instances; hand-edited scenario blocks in archives (k6 run archive.tar); CI pipelines that assemble options from environment variables or flags without local validation.","solutions":["Read the text after the colon - the wrapped cause names the exact failure, and the scenario name before it identifies the offending entry in options.scenarios","Validate locally without running load: `k6 inspect --execution-requirements script.js` parses options and shows the planned executors","If using --execution-segment / --execution-segment-sequence, verify the sequence partitions [0,1] and every segment fits it (0<=start<end<=1, segments tiled onto the sequence)","Bisect: temporarily reduce scenarios to a single executor and re-add the others until the failing one is isolated"],"exampleFix":"# before: segment not representable in the given sequence\nk6 run --execution-segment '3/8:5/8' --execution-segment-sequence '0,1/8,3/8,7/8' script.js\n# segment [3/8,5/8) cannot be expressed by that sequence -> executor Init fails\n\n# after: sequence that contains both cut points 3/8 and 5/8\nk6 run --execution-segment '3/8:5/8' --execution-sequence '0,3/8,5/8,1' script.js 2>/dev/null || \\\nk6 run --execution-segment '3/8:5/8' --execution-segment-sequence '0,3/8,5/8,1' script.js","handlingStrategy":"validation","validationCode":"# CI pre-flight: parses scenarios and computes executor requirements without running load\nk6 inspect --execution-requirements script.js > /dev/null || exit 1\n\n# sanity-check segment flags before distributing a run\nk6 inspect --execution-requirements \\\n  --execution-segment '3/8:5/8' \\\n  --execution-segment-sequence '0,3/8,5/8,1' script.js > /dev/null || exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run k6 inspect in CI before launching load - it exercises the same config parsing path","Keep execution segment sequences explicit when sharding so every segment's endpoints appear in the sequence","When options come from env/flags, generate them from one validated template instead of assembling per-job"],"tags":["executor","scenarios","execution-segment","startup","configuration"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}