grafana/k6 · error

flushing data to disk

Error message

flushing data to disk: %w

What it means

Raised in LocalFilePersister.Persist when bufio.Writer.Flush fails after all bytes were copied into the buffer, meaning buffered artifact data could not be committed to the underlying file. Typical causes are disk-full or I/O errors surfacing only at flush time. The file exists but its contents may be incomplete because buffered bytes were lost.

Solutions

  1. Free disk space and retry the persist
  2. Check dmesg/system logs for underlying device I/O errors
  3. Delete the potentially incomplete artifact file before retrying
  4. Consider a larger buffer size or unbuffered writes if flush failures recur
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/storage/file_persister.go:49 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/e54dde435b4ce045. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/storage/file_persister.go:49

	f, err := os.OpenFile(cp, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) //nolint:forbidigo
	if err != nil {
		return fmt.Errorf("creating a local file %q: %w", cp, err)
	}
	defer func() {
		if cerr := f.Close(); cerr != nil && err == nil {
			err = fmt.Errorf("closing the local file %q: %w", cp, cerr)
		}
	}()

	bf := bufio.NewWriter(f)

	if _, err := io.Copy(bf, data); err != nil {
		return fmt.Errorf("copying data to file: %w", err)
	}

	if err := bf.Flush(); err != nil {
		return fmt.Errorf("flushing data to disk: %w", err)
	}

	return nil
}

// RemoteFilePersister is to be used when files created by the browser module need
// to be uploaded to a remote location. This uses a presignedURLRequestURL to
// retrieve one presigned URL. The presigned url is used to upload the file
// to the remote location.
type RemoteFilePersister struct {
	presignedURLRequestURL string
	headers                map[string]string
	basePath               string

	httpClient *http.Client
}

// PresignedURLResponse holds the response from a presigned generation request.

View on GitHub (pinned to 8d06114777)