ipfs/kubo · error

compressing result %q: %w

Error message

compressing result %q: %w

What it means

After archive.Create succeeds, runProfile copies the profile bytes with io.Copy(out, res.buf); if that copy fails the error is wrapped as "compressing result %q". Despite the wording, this is almost always a write-side I/O failure while streaming compressed profile data into the archive (or a read failure of the in-memory buffer, which is rare). It aborts the whole WriteProfiles run with the failing profile's name in the message.

Source

Thrown at profile/profile.go:194

			}
		}(c)
	}
	go func() {
		wg.Wait()
		close(results)
	}()

	for res := range results {
		if res.err != nil {
			return res.err
		}
		out, err := p.archive.Create(res.fName)
		if err != nil {
			return fmt.Errorf("creating output file %q: %w", res.fName, err)
		}
		_, err = io.Copy(out, res.buf)
		if err != nil {
			return fmt.Errorf("compressing result %q: %w", res.fName, err)
		}
	}

	return nil
}

func goroutineStacksText(ctx context.Context, _ Options, w io.Writer) error {
	return WriteAllGoroutineStacks(w)
}

func goroutineStacksProto(ctx context.Context, _ Options, w io.Writer) error {
	return pprof.Lookup("goroutine").WriteTo(w, 0)
}

func heapProfile(ctx context.Context, _ Options, w io.Writer) error {
	return pprof.Lookup("heap").WriteTo(w, 0)
}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Check free disk space and file-size limits (df, ulimit -f) at the archive destination
  2. Inspect the wrapped error for the concrete write failure (ENOSPC, EPIPE, etc.)
  3. Retry the diagnostics capture after freeing space or pointing the archive at a writable location
  4. Verify nothing closes or truncates the output file while WriteProfiles is running
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(destDir)
if err != nil || !info.IsDir() {
    return fmt.Errorf("archive destination missing")
}
if usable, err := freeBytes(destDir); err == nil && usable < minNeeded {
    return fmt.Errorf("insufficient space for profile archive")
}

Try / catch

if err := WriteProfiles(ctx, p); err != nil {
    if strings.HasPrefix(err.Error(), "compressing result") {
        // check ENOSPC/EPIPE and retry after freeing space or switching output
        if errors.Is(errors.Unwrap(err), syscall.ENOSPC) {
            log.Println("disk full: free space and retry")
        }
    }
    return err
}

Prevention

When it happens

Trigger: io.Copy(out, res.buf) returns an error while writing the compressed entry: disk full, output file/connection closed or reset, archive encoder failure (e.g. flate/gzip writer error), or the underlying file descriptor hitting a limit.

Common situations: Capturing large heap/goroutine dumps on a small tmpfs or nearly-full volume; network or pipe-backed archive outputs being interrupted; ulimit -f (max file size) truncating the output.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/0cc4d1ce36eaf4e7. Report an issue: GitHub.