{"record":{"id":"b002d261e55629e4","repo":"grafana/k6","slug":"error-saving-summary-to-s-after-d-bytes-w","errorCode":null,"errorMessage":"error saving summary to '%s' after %d bytes: %w","messagePattern":"error saving summary to '(.+?)' after (.+?) bytes: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/run.go","lineNumber":596,"sourceCode":"func handleSummaryResult(fs fsext.Fs, stdOut, stdErr io.Writer, result map[string]io.Reader) error {\n\tvar errs []error\n\n\tgetWriter := func(path string) (io.Writer, error) {\n\t\tswitch path {\n\t\tcase \"stdout\":\n\t\t\treturn stdOut, nil\n\t\tcase \"stderr\":\n\t\t\treturn stdErr, nil\n\t\tdefault:\n\t\t\treturn fs.OpenFile(path, syscall.O_WRONLY|syscall.O_CREAT|syscall.O_TRUNC, 0o666)\n\t\t}\n\t}\n\n\tfor path, value := range result {\n\t\tif writer, err := getWriter(path); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"could not open '%s': %w\", path, err))\n\t\t} else if n, err := io.Copy(writer, value); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"error saving summary to '%s' after %d bytes: %w\", path, n, err))\n\t\t}\n\t}\n\n\treturn consolidateErrorMessage(errs, \"Could not save some summary information:\")\n}\n","sourceCodeStart":578,"sourceCodeEnd":602,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/run.go#L578-L602","documentation":"After successfully opening a summary output file, k6 streams the rendered summary with io.Copy. If the write fails partway (disk full, quota exceeded, network filesystem drop), the error is wrapped with the number of bytes already written: \"error saving summary to '<path>' after N bytes: ...\". All such errors are consolidated under 'Could not save some summary information:'.","triggerScenarios":"The disk fills during the summary write at end of test; a container exceeds its writable-layer size limit; an NFS/SMB mount fails mid-write; the file was opened with O_TRUNC on a path that becomes unwritable.","commonSituations":"Long-running tests on small CI volumes where archives and summaries compete for space; Docker containers with storage size limits; summaries written to mounted volumes with quotas.","solutions":["Free disk space or raise the volume/quota, then re-run the test","Write the summary to 'stdout' in handleSummary and let the shell/CI redirect it to a file","Add a pre-run check that the output volume has space (df) and is writable (touch test file)","Reduce summary size by exporting only the metrics you need from data.metrics in handleSummary"],"exampleFix":"# before\nk6 run --summary-export=/mnt/vol/summary.json script.js\n# after\nk6 run script.js > run.log 2>&1; k6 run ... | tee summary.json  # summary via stdout, file managed by shell","handlingStrategy":"validation","validationCode":"# Guard disk space and writability before long runs\ndf -hP out | awk 'NR==2 {gsub(\"%\",\"\",$5); if ($5+0 > 90) exit 1}' || { echo 'low disk' >&2; exit 2; }\ntouch out/.wtest 2>/dev/null && rm -f out/.wtest || { echo 'out/ not writable' >&2; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit summaries to stdout and let the shell/CI write the file","Prune old artifacts between CI runs","Monitor volume usage during soak tests","Export filtered, small summaries instead of all metrics"],"tags":["summary","filesystem","io","disk-full"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}