fix(resource-monitoring): fix lsof file descriptor leak#9568
fix(resource-monitoring): fix lsof file descriptor leak#9568RomneyDa merged 4 commits intocontinuedev:mainfrom
Conversation
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
There was a problem hiding this comment.
3 issues found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="extensions/cli/src/services/ResourceMonitoringService.test.ts">
<violation number="1" location="extensions/cli/src/services/ResourceMonitoringService.test.ts:124">
P2: Leak regression test is ineffective: it performs no assertion when lsof is unavailable and doesn’t verify lsof call frequency, so a leak can slip through undetected.</violation>
<violation number="2" location="extensions/cli/src/services/ResourceMonitoringService.test.ts:137">
P2: FD refresh interval test never exercises refresh and has no effective assertion; it always passes even if refresh doesn’t occur.</violation>
</file>
<file name="extensions/cli/src/services/ResourceMonitoringService.ts">
<violation number="1" location="extensions/cli/src/services/ResourceMonitoringService.ts:134">
P1: updateFileDescriptorCount() runs on every getCurrentResourceUsage call, spawning lsof every second despite intended 5s throttling</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
tests for this pr:
|
|
🎉 This PR is included in version 1.41.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |

Description
Add caching mechanism for file descriptor count to avoid frequent lsof command execution. Implement periodic updates with configurable interval to maintain accuracy while preventing resource leaks. Add tests to verify caching behavior and update intervals.
Fixes: continue cli leaking
lsofexecs · Issue #9422 · continuedev/continueAI Code Review
@continue-reviewChecklist
Screen recording or screenshot
[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]
Tests
Check which process is running the target script
Run the following command to find the process:
Observe the output and note the PID
→ The process ID (PID) is 13448.
Create a simple monitoring script to watch lsof behavior on that PID
Create a bash script (for example
monitor.sh) with the following content:Run the monitoring script
Execute it in the background or in another terminal:
(or
./monitor.shafterchmod +x monitor.sh)Observe the result
You will see frequent/tight timestamps whenever the command
lsof -p 13448is actively running:Continue Tasks:▶️ 2 queued · ▶️ 1 not started — View all