Repository navigation
fix(mcp): join auto-watch before closing its GraphStore - #1127
Merged
1 commit merged intoNov 6, 2026
Merged
1 commit merged into
1 commit merged into
Conversation
code-review-graph reviewOverall risk: 0.65 (MEDIUM) — 37 changed function(s)/class(es), 45 affected flow(s), 1 test gap(s) Risk-scored changes
Affected execution flows
Test gaps
Powered by code-review-graph — local-first analysis; no code leaves the CI runner. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the watcher shutdown-ordering change.
No open issues 🎉
What changed in this PR
Fixes #1121 by ensuring MCP auto-watch finishes in-flight work before its GraphStore is closed, preventing use-after-close during shutdown.
Changes:
- Retains the watcher thread, signals it to stop, and joins it without a timeout before closing the store.
- Adds an optional stop event to
start_watch_thread()while preserving positional argument compatibility. - Adds shutdown-ordering regressions for returning and raising transports, plus unavailable or failed watcher startup.
| File | Description |
|---|---|
tests/test_mcp_watch_store_shutdown.py |
Adds event-gated lifecycle tests, with conditional post-processing coverage. |
code_review_graph/main.py |
Orders shutdown as stop → join → close and restores the stdio flag even if cleanup raises. |
code_review_graph/incremental.py |
Accepts and forwards an optional watcher stop event. |
Review effort: Balanced
0160eb0
gowrishacv
pushed a commit
to gowrishacv/code-review-graph
that referenced
this pull request
Nov 6, 2026
… post-processing Both PRs change start_watch_thread and main(). Keep the callback and the stop event. Tests that ended the watcher with a patched time.sleep now use the stop event, because the loop no longer sleeps when one is given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gowrishacv
pushed a commit
to gowrishacv/code-review-graph
that referenced
this pull request
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MCP auto-watch currently closes its GraphStore as soon as the transport ends, even while startup reconciliation or a debounced event batch is using it. Retain the watcher thread, signal its existing stop event, and join it before closing the store. Shutdown waits for in-flight work without a timeout that could reintroduce use-after-close; the stdio flag is restored even if cleanup raises.
Closes #1121.
Validation follows a reproduce/fix/regression approach:
09dca915: 10 passed, including startup and batch post-processing with both returning and raising transports. This PR does not include fix(mcp): run post-processing during auto-watch updates #1108's independent FTS changes.--platform linux, matching CI), and Bandit pass.The regression retains the real watcher, handler and debouncer and replaces only external boundaries. It checks that close occurs once after all workers exit and holds operations past the watcher's short join timeout. No real SQLite connection is opened by that reproduction.
GitHub CI on
68ffef3: 17 successful checks, including Python 3.10–3.13 (5,051 passed per version, 86.65–86.69% coverage), browser tests, MCP end-to-end tests on Linux/macOS/Windows, and native Windows resource/daemon tests. The manual upgrade-path check is skipped as configured. No merge conflicts with staging.