Skip to content

Conversation

@snakefoot
Copy link
Contributor

Resolves #5951

@snakefoot snakefoot added bug Bug report / Bug fix file-target labels Aug 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 7, 2025

Warning

Rate limit exceeded

@snakefoot has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 29 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 43ae156 and f3042f2.

📒 Files selected for processing (5)
  • src/NLog/Targets/ConsoleWordHighlightingRule.cs (1 hunks)
  • src/NLog/Targets/FileTarget.cs (1 hunks)
  • tests/NLog.Targets.ConcurrentFile.Tests/ConcurrentFileTargetTests.cs (2 hunks)
  • tests/NLog.UnitTests/Targets/AsyncTaskTargetTest.cs (1 hunks)
  • tests/NLog.UnitTests/Targets/FileTargetTests.cs (8 hunks)

Walkthrough

This change set modifies file cache management in the FileTarget class to correct the logic for closing open file handles, updates associated unit and integration tests to explicitly control file deletion and verify handle release, and adjusts XML documentation in a console highlighting rule. No public API changes are introduced.

Changes

Cohort / File(s) Change Summary
File Cache Control Logic
src/NLog/Targets/FileTarget.cs
Inverts the break condition in the PruneOpenFileCache method, ensuring the loop only continues when a valid file key exists, affecting when file handles are closed.
Test Adjustments for File Handle Release
tests/NLog.UnitTests/Targets/FileTargetTests.cs, tests/NLog.Targets.ConcurrentFile.Tests/ConcurrentFileTargetTests.cs
Updates tests to explicitly set EnableFileDelete = false, adjust file deletion assertions, and verify file handles are released according to OpenFileCacheSize. Adds checks for undeletable files and ensures test cleanup after assertions.
Documentation Update
src/NLog/Targets/ConsoleWordHighlightingRule.cs
Removes a redundant requirement phrase from the XML documentation comment for the Text property; no functional code changes.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Unit Test
    participant FileTarget as FileTarget
    participant FileSystem as File System

    Test->>FileTarget: Log messages to multiple files
    FileTarget->>FileSystem: Open file handles (up to OpenFileCacheSize)
    FileTarget->>FileSystem: Write log entries
    Test->>FileTarget: Flush logs and attempt file deletion
    FileTarget->>FileSystem: Release file handles as per cache logic
    Test->>FileSystem: Delete files, assert deletion
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Ensure FileTarget respects OpenFileCacheSize and limits open file handles (#5951)
Prevent unbounded increase in process handle count when logging to multiple files (#5951)
Add or adjust tests to verify file handle release and cache behavior (#5951)

Poem

A cache of files, now neat and small,
Handles pruned, no leaks at all.
Tests ensure the doors are closed,
No more handles indisposed!
With docs tidied and logic tight,
This bunny hops with pure delight. 🐇✨


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@snakefoot snakefoot force-pushed the dev branch 2 times, most recently from a9384ca to 43ae156 Compare August 7, 2025 17:08
@snakefoot snakefoot closed this Aug 7, 2025
@snakefoot snakefoot reopened this Aug 7, 2025
@snakefoot snakefoot force-pushed the dev branch 2 times, most recently from 578f5d9 to f3042f2 Compare August 7, 2025 17:53
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug report / Bug fix file-target size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileTarget ignores OpenFileCacheSize property, process Handles count increases

1 participant