Skip to content

internal/driver: close saved profile files - #1022

Open
cuishuang wants to merge 3 commits into
google:mainfrom
cuishuang:fix-Profile.Write
Open

internal/driver: close saved profile files#1022
cuishuang wants to merge 3 commits into
google:mainfrom
cuishuang:fix-Profile.Write

Conversation

@cuishuang

Copy link
Copy Markdown
Contributor

Remote profiles are saved to an *os.File returned by newTempFile, but the file was not closed after Profile.Write returned.

This is mostly hidden for short-lived CLI invocations, but leaks file descriptors when pprof is used repeatedly from a long-lived process.

Close the saved profile file after writing, treat close failures as save failures, and only print the success message when both writing and closing succeed. Preserve the write error if both operations fail.

Add tests covering successful writes, write failures, close failures, and combined write and close failures.

Tests:

  • ./test.sh

Signed-off-by: cuishuang <imcusg@gmail.com>
Comment thread internal/driver/fetch_test.go Outdated
@codecov-commenter

codecov-commenter commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.40%. Comparing base (4d45320) to head (c2eb7ac).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1022      +/-   ##
==========================================
+ Coverage   67.38%   67.40%   +0.02%     
==========================================
  Files          45       45              
  Lines        7846     7852       +6     
==========================================
+ Hits         5287     5293       +6     
  Misses       2115     2115              
  Partials      444      444              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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