Skip to content

fix: preserve flame graphs when export fails - #412

Merged
Byron merged 2 commits into
Byron:mainfrom
Likio3000:fix/atomic-flamegraph-export
Oct 5, 2026
Merged

Byron merged 2 commits into
Byron:mainfrom
Likio3000:fix/atomic-flamegraph-export

Conversation

@Likio3000

Copy link
Copy Markdown
Contributor

Running dua flamegraph --output usage.svg empty-directory returns No stack counts found, but currently overwrites an existing usage.svg before reporting that error. This change renders to a temporary file in the destination directory, flushes and syncs it, and atomically replaces the output only after rendering succeeds, following the existing snapshot-export pattern.

Regression tests cover preserving a previously generated report on failure, leaving no partial report or temporary files when the output does not exist, and successfully replacing an existing report. Both failure regressions were confirmed against the original implementation before applying the fix. No dependencies were added.

Validation on Linux with Rust 1.98.0:

  • All five feature configurations in make check, using --locked.
  • Workspace tests: 284 passed with default features; 160 passed with --no-default-features --features trash-move.
  • All 23 stateless journey cases passed.
  • cargo fmt --all -- --check and cargo clippy --locked -- -D warnings passed.

AI assistance: Codex. Model attribution requested by the author: GPT-6 Astra (exact model identifier unverified).

@Byron
Byron requested a balanced review from Copilot October 5, 2026 02:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unix exports reset report permissions, potentially making reports unreadable to other users or services.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Protects existing flame graph reports from failed exports by following the snapshot export’s temporary-file pattern.

Changes:

  • Render, flush, and sync a temporary file before atomically replacing the output.
  • Add regression tests for preservation, cleanup, and successful replacement.
File Description
tests/​stack_commands.rs Tests failed exports and successful report replacement.
src/​main.rs Stages flame graph output before installation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main.rs Outdated
- simplify. Notably a lot of tests were removed as well, keeping only the essential one.

Assisted-by: GPT 6.1 Sol
Co-authored-by: GPT 6.1 Sol <codex@openai.com>
@Byron
Byron merged commit d11cb9c into Byron:main Oct 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants