{"record":{"id":"daa6c7a0a67caed1","repo":"grafana/k6","slug":"105","errorCode":"105","errorMessage":"test run was aborted because k6 received a '%s' signal","messagePattern":"test run was aborted because k6 received a '(.+?)' signal","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/cmd/run.go","lineNumber":409,"sourceCode":"\tdefer func() {\n\t\tlogger.Debug(\"Waiting for metrics processing to finish...\")\n\t\tclose(samples)\n\t\twaitOutputsFlushed()\n\t\tlogger.Debug(\"Metrics processing finished!\")\n\t}()\n\n\tprintExecutionDescription(\n\t\tc.gs, \"local\", args[0], \"\", conf, executionState.ExecutionTuple, executionPlan, outputs,\n\t)\n\n\t// Trap Interrupts, SIGINTs and SIGTERMs.\n\t// TODO: move upwards, right after runCtx is created\n\tgracefulStop := func(sig os.Signal) {\n\t\tlogger.WithField(\"sig\", sig).Debug(\"Stopping k6 in response to signal...\")\n\t\t// first abort the test run this way, to propagate the error\n\t\trunAbort(errext.WithAbortReasonIfNone(\n\t\t\terrext.WithExitCodeIfNone(\n\t\t\t\tfmt.Errorf(\"test run was aborted because k6 received a '%s' signal\", sig), exitcodes.ExternalAbort,\n\t\t\t), errext.AbortedByUser,\n\t\t))\n\t\tlingerCancel() // cancel this context as well, since the user did Ctrl+C\n\t}\n\tonHardStop := func(sig os.Signal) {\n\t\tlogger.WithField(\"sig\", sig).Error(\"Aborting k6 in response to signal\")\n\t\tglobalCancel() // not that it matters, given that os.Exit() will be called right after\n\t}\n\tstopSignalHandling := handleTestAbortSignals(c.gs, gracefulStop, onHardStop)\n\tdefer stopSignalHandling()\n\n\t// Initialize the VUs and executors\n\tstopVUEmission, err := execScheduler.Init(runCtx, samples)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer stopVUEmission()\n","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/cmd/run.go#L391-L427","documentation":"k6 traps SIGINT and SIGTERM for the duration of a local run. On the first signal it gracefully stops the test, propagates this error (exit code 105, ExternalAbort, abort reason AbortedByUser), and cancels lingering contexts. A second signal triggers the hard-stop path instead. The signal name is included in the message.","triggerScenarios":"Ctrl+C in a terminal; CI/container runtimes sending SIGTERM on job timeout or pod eviction; `timeout 60 k6 run ...`; systemd stop; orchestrators signaling the whole process group.","commonSituations":"Kubernetes pod eviction mid-test; CI step time limits smaller than the scripted duration; shared agents reaping long jobs; accidental double Ctrl+C.","solutions":["If you stopped the test intentionally, no fix is needed — this is the expected outcome","In CI, raise the job/step timeout so k6 finishes before the runner sends SIGTERM","For containers/orchestrators, allow a generous graceful termination period before SIGKILL so k6 can flush metrics and the summary","Treat exit code 105 as 'cancelled/aborted by user', not as a test failure, in pipeline result mapping"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"# distinguish user/system aborts (105) from real failures\nk6 run script.js\nec=$?\nif [ \"$ec\" -eq 105 ]; then\n  echo \"test aborted by SIGINT/SIGTERM — marking job as cancelled\" >&2\n  exit 0   # or a dedicated 'cancelled' status\nfi\nexit \"$ec\"","preventionTips":["Size CI timeouts larger than the longest planned test duration plus teardown","Set graceful termination periods (terminationGracePeriodSeconds, docker stop -t) above k6's teardown needs","Avoid sending a second signal immediately — the first already triggers graceful stop","Record signal-based aborts separately in dashboards so they don't pollute failure metrics"],"tags":["k6","signals","sigterm","sigint","exit-code-105","abort"],"backgroundTag":"sigterm-abort","analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}