ipfs/kubo · error
creating output file %q: %w
Error message
creating output file %q: %w
What it means
runProfile consumes collected profile results and adds each one to the output archive via p.archive.Create(res.fName). This error means the archive writer refused to create the named entry for a profile. It is wrapped with the entry name so the developer knows which profile entry failed; the root cause is on the archive/underlying writer side, not profile collection.
Source
Thrown at profile/profile.go:190
}
select {
case results <- profileResult{buf: &b, fName: fName}:
case <-ctx.Done():
}
}(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)
}
View on GitHub (pinned to 329838acdf)
Solutions
- Inspect the wrapped error from archive.Create — it names the underlying cause (closed writer, path, permission)
- Keep the archive open until runProfile has fully drained the results channel (do not close it concurrently or early)
- Verify the output destination (file/mount) is writable and has free space
- Check fName for characters the archive format disallows
Example fix
// before archive, _ := archiveBuilder(p.outputFile) archive.Close() // closed too early err := WriteProfiles(ctx, p) // Create fails: writer closed // after archive, _ := archiveBuilder(p.outputFile) err := WriteProfiles(ctx, p) archive.Close() // close only after profiles are written
Defensive patterns
Strategy: try-catch
Validate before calling
f, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
return fmt.Errorf("archive destination unwritable: %w", err)
}
f.Close() Try / catch
err := WriteProfiles(ctx, p)
if err != nil {
if strings.HasPrefix(err.Error(), "creating output file") {
log.Printf("archive entry creation failed, check archive lifetime/disk: %v", errors.Unwrap(err))
}
return err
} Prevention
- Never close the archive writer before runProfile drains the results channel
- Verify the output path is on a writable, non-full filesystem before starting
- Use standard archive entry names (no path separators or duplicate names)
- Let WriteProfiles own the archive lifecycle end-to-end
When it happens
Trigger: p.archive.Create(fName) returns an error: the underlying archive writer was already closed or corrupted, the backing output file became unwritable mid-run, the archive implementation rejects the fName (invalid/duplicate entry name), or the underlying io.Writer to disk failed.
Common situations: Writing a diagnostics archive to a full disk or read-only mount; closing the archive writer before runProfile finishes draining the results channel; custom archive implementations that reject entry names.
Related errors
- compressing result %q: %w
- opening binary %q: %w
- copying binary %q: %w
- e (stream error trailer header value)
- cannot read migration: %w
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/80f5fb482b8033ad.
Report an issue: GitHub.