fix: close Reader on File::Reset#3784
Conversation
Signed-off-by: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com>
WalkthroughAdds a safeguard in File.Reset() to close an existing non-nil reader before setting it to nil. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant File
participant Reader
Caller->>File: Reset()
alt reader is non-nil
File->>Reader: Close()
Reader-->>File: close result
File->>File: set reader = nil
else reader is nil
File->>File: no-op
end
File-->>Caller: return
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3784 +/- ##
=======================================
Coverage 91.67% 91.68%
=======================================
Files 113 113
Lines 11959 11962 +3
=======================================
+ Hits 10964 10967 +3
Misses 731 731
Partials 264 264
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
client/request.go (1)
957-965: Update SetReader doc comment. Replace the comment on line 951 to note that the reader is closed in both the parserBody hook and in Reset.
🧹 Nitpick comments (1)
client/request.go (1)
951-951: Update comment to reflect that Reset() also closes the reader.The comment states the reader "will be closed in the parserBody hook," but with the changes in this PR, Reset() also closes the reader. Consider updating this comment to accurately reflect both cleanup paths.
Apply this diff to update the comment:
-// SetReader sets the file's reader, which will be closed in the parserBody hook. +// SetReader sets the file's reader, which will be closed in the parserBody hook or during Reset().
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
client/request.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/*.go: Format Go code using gofumpt (enforced viamake format)
Ensure code passes golangci-lint checks (enforced viamake lint)
Optimize struct field alignment using betteralign (enforced viamake betteralign)
Modernize Go code using gopls modernize (enforced viamake modernize)
Files:
client/request.go
|
I think benchmark result is not relevant in this case |
Description
Fix to close file descriptors on
Request::Reset()Currently file can be opened here and never closed
fiber/client/hooks.go
Lines 288 to 294 in a33bab1
Changes introduced
List the new features or adjustments introduced in this pull request. Provide details on benchmarks, documentation updates, changelog entries, and if applicable, the migration guide.
Type of change
Please delete options that are not relevant.
Checklist
Before you submit your pull request, please make sure you meet these requirements:
/docs/directory for Fiber's documentation.Commit formatting
Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md