[mcp] fix: bound stops waiting on startup - #148
Conversation
|
Warning Review limit reached
Next review available in: 21 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: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds bounded waiting and pending-stop tracking to ChangesStop Starting Session Timeout
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Code Review
This pull request introduces bounded waiting for starting sessions during stop and stop-all requests to prevent indefinite blocking when a startup hangs. If a startup does not settle within the timeout budget, the stop request returns a timeout payload, and a background thread is spawned to release the session once startup eventually completes. The reviewer suggests removing the "quiet=True" argument from the background stop thread to ensure that session releases and potential failures are properly logged for auditability and observability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
docs/plans/stop-starting-session-timeout.md (1)
1-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMove this plan into a dedicated docs subfolder.
This is a detailed plan for a non-trivial lifecycle change, but it is added directly under
docs/plans/instead of under a descriptive folder such asdocs/plans/stop-starting-session-timeout/plan.md. Grouping it under its own subdirectory will keep the related documentation easier to evolve together.As per coding guidelines, "For complex features, bug investigations, or refactorings that require detailed documentation, create a dedicated subfolder under
docs/with a descriptive name and place all related documentation files there."🤖 Prompt for 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. In `@docs/plans/stop-starting-session-timeout.md` around lines 1 - 85, The plan document is placed directly under docs/plans instead of in a dedicated feature subfolder, which makes the related documentation harder to keep together. Move this document into a descriptive subdirectory under docs/plans for the stop-starting-session-timeout feature and update any references so the plan remains the canonical document; use the existing Stop Starting Session Timeout Plan heading and the docs/plans path as the main identifiers when relocating it.Source: Coding guidelines
🤖 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/keep_gpu/mcp/server.py`:
- Around line 213-225: The startup-wait logic in
_wait_for_starting_jobs_or_mark_pending and the stop-all path must stop keying
state only by reusable job_id strings. Introduce an immutable per-start token or
generation in the starting snapshot so each session start is uniquely tracked
even if the same job_id is reused, and use that token when deciding
still_starting and when updating _pending_stop_job_ids. Also update the stop-all
snapshot/release flow (the code around the related wait/stop helpers) to wait
briefly for startup to settle before returning not found or marking timed-out
sessions, so a later startup cannot be misattributed to an earlier stop request.
In `@tests/mcp/test_server.py`:
- Around line 1502-1507: The blocking fake controllers in the MCP server tests
are using timed waits, which can self-unblock and make the timeout-path
concurrency tests flaky. Update the stuck-controller helpers such as
BlockingStartController.keep and the other related fake controller methods in
this test module to wait deterministically until the cleanup signals are set,
rather than using a timeout-based wait. Keep the existing event signaling in the
test cleanup/finally blocks so the tests only proceed when the stop path
explicitly releases them.
---
Nitpick comments:
In `@docs/plans/stop-starting-session-timeout.md`:
- Around line 1-85: The plan document is placed directly under docs/plans
instead of in a dedicated feature subfolder, which makes the related
documentation harder to keep together. Move this document into a descriptive
subdirectory under docs/plans for the stop-starting-session-timeout feature and
update any references so the plan remains the canonical document; use the
existing Stop Starting Session Timeout Plan heading and the docs/plans path as
the main identifiers when relocating it.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: faa356b3-c863-40a1-b3a6-c4ca8d470fed
📒 Files selected for processing (6)
AGENTS.mddocs/guides/mcp.mddocs/plans/stop-starting-session-timeout.mddocs/reference/cli.mdsrc/keep_gpu/mcp/server.pytests/mcp/test_server.py
…top-wait # Conflicts: # AGENTS.md # README.md # docs/concepts/architecture.md # docs/guides/mcp.md # docs/plans/stop-starting-session-timeout.md # docs/reference/cli.md # src/keep_gpu/mcp/server.py # tests/mcp/test_server.py
|
CodeRabbit nitpick on plan location: keeping |
Summary
stop_keepwaits for sessions stuck instartingso stop requests do not hang indefinitely.Test Plan
PYTHONPATH=$PWD/src pytest tests/mcp/test_server.py::test_stop_keep_times_out_waiting_for_stuck_starting_session tests/mcp/test_server.py::test_stop_all_times_out_waiting_for_stuck_starting_session tests/mcp/test_server.py::test_timed_out_stop_of_starting_session_releases_after_startup_completes tests/mcp/test_server.py::test_timed_out_stop_of_failed_startup_does_not_affect_reused_job_id tests/mcp/test_server.py::test_stop_all_does_not_duplicate_starting_timeout_after_startup_settles tests/mcp/test_server.py::test_stop_keep_waits_for_starting_session tests/mcp/test_server.py::test_stop_all_waits_for_starting_session tests/mcp/test_server.py::test_stop_all_waits_only_for_sessions_starting_at_snapshot -q-> 8 passedPYTHONPATH=$PWD/src pytest tests/mcp -q-> 184 passedPYTHONPATH=$PWD/src pytest tests -q-> 626 passed, 11 skippedpre-commit run --all-files-> passedPYTHONPATH=$PWD/src mkdocs build-> passed with existing Material warning and unnav'd plan noticesgit diff --check-> passedLocal Review
Summary by CodeRabbit