fix(upstream): retain capacity through child cleanup - #239
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesUpstream teardown coordination
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant UpstreamProcessManager
participant StdioClientTransport
participant TransportCloseSignal
participant CapacityLimiter
UpstreamProcessManager->>StdioClientTransport: terminate transport
StdioClientTransport->>TransportCloseSignal: resolve local close
UpstreamProcessManager->>TransportCloseSignal: complete teardown gate
UpstreamProcessManager->>CapacityLimiter: release profile capacity
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/upstream/upstream-process-manager.ts`:
- Around line 1131-1150: The pending teardown path in deferTeardown can retain
profile capacity indefinitely without surfacing its state. Add periodic
diagnostic warnings or equivalent health metadata for teardown gates that remain
unresolved, including the profile and pending-since time, while preserving the
existing completion and capacity-release behavior in completeTeardown and
releaseProfileCapacity.
In `@tests/upstream-manager.test.ts`:
- Around line 877-885: Update the test cleanup around the second successful
manager.get("work") call to re-read the replacement descendant PID from
descendantPidPath and assign it to descendantPid before entering cleanup,
ensuring the finally block terminates the replacement descendant as well as the
upstream process.
- Around line 797-840: Update the test’s StdioClientTransport tracking to use
its public pid and onclose APIs instead of reading the private _process handle.
In the mocked start implementation, record the first transport’s pid and use
onclose to set firstChildClosed, preserving the assertion that replacement
startup waits for shutdown.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 185a52aa-96dc-42ce-8b77-71d4f0c872b7
📒 Files selected for processing (3)
src/upstream/upstream-process-manager.tstests/fixtures/retained-stdio-descendant.mjstests/upstream-manager.test.ts
Closes #205
Summary
Root cause
The MCP SDK can return from its SIGKILL shutdown path before the child process emits
close. Miftah could release capacity or start a replacement in that gap. The regression fix briefly returned early for remote transports, which skipped aborting a timed-out DELETE; this PR restores that existing remote cleanup contract.Validation
npm test(122 files passed, 1 skipped; 1557 tests passed, 27 skipped)npm run test:corenpm run test:coverage(95.77% statements, 91.94% branches, 98.33% functions)npm run lintnpm run typechecknpm run buildnpm run smoke:clinpm run check:packnpm run test:packageIndependent local review completed; no remaining actionable lifecycle defect found.
Summary by CodeRabbit