Test#8
Conversation
…date documentation formatting
Changes Made (convex/mcp.ts:11-114)
1. Added Connection Guard (Line 12)
const pendingConnections = new Map<string, Promise<void>>()
2. Updated connectLLMText with Race Protection (Lines 19-66)
- ✅ Checks if connection is already in progress → waits for it
- ✅ Checks if already connected → returns immediately
- ✅ Stores pending connection promise before starting
- ✅ Cleans up in finally block to prevent memory leaks
- ✅ Concurrent callers now wait for the same connection attempt
3. Fixed extractText to Delegate (Lines 82-85)
// OLD (race condition):
await manager.connect({ ... }) // Multiple callers = multiple connects
// NEW (safe):
await ctx.runAction(internal.mcp.connectLLMText, {}) // Delegates to guarded function
How It Works
Before: Multiple concurrent extractText calls → All see "not connected" → All try to connect → Race condition
After: Multiple concurrent calls → First starts connection, others wait for same promise → Only one connection
attempt
Benefits
- 🛡️ Thread-safe: No duplicate connection attempts
- 🚀 Efficient: Concurrent callers share the same connection
- 🔒 Memory-safe: Automatic cleanup in finally block
- 📝 Self-documenting: Clear inline comments
… token.
Changes Made (.github/workflows/setup-github-projects_Version3.yml:31-42)
Before:
env:
GH_TOKEN_SECRET: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN_SECRET: ${{ secrets.GITHUB_TOKEN }}
After:
env:
MY_GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
Key improvements:
- ✅ Now uses your MY_GITHUB_TOKEN secret
- ✅ Cleaner error handling if token is missing
- ✅ Clear success message when authenticated
Next Steps
1. Commit the workflow:
git add .github/workflows/setup-github-projects_Version3.yml
git commit -m "fix: Use MY_GITHUB_TOKEN for issue creation"
git push
2. Run the workflow:
- Go to GitHub Actions → "Import Plan to Issues"
- Click "Run workflow"
- Should now successfully create all 136 issues
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughUpdates GitHub workflow to require Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant extractText
participant connectLLMText
participant MCPMutations as "mcp_mutations (DB)"
participant MCPClient as "llm-txt client"
Note right of Caller: New high-level MCP connect & extract flow
Caller->>extractText: extractText(url)
extractText->>connectLLMText: ensure connection(serverName)
connectLLMText->>MCPMutations: acquireConnectionLock(serverName)
alt acquired lock
connectLLMText->>MCPClient: connect llm-txt
MCPClient-->>connectLLMText: connected
connectLLMText->>MCPMutations: storeConnection(serverName, "connected", now)
connectLLMText-->>extractText: alreadyConnected: true
else existing connecting (not acquired)
connectLLMText->>MCPMutations: await lock outcome / check status
connectLLMText-->>extractText: waited: true
else failed to acquire (connected elsewhere)
connectLLMText-->>extractText: alreadyConnected: true
end
extractText->>MCPClient: perform extraction
alt extraction success
extractText->>MCPMutations: storeExtraction(url, text, format, now)
extractText-->>Caller: extracted text
else extraction failure
extractText->>MCPMutations: updateConnectionStatus(serverName, "failed", error)
extractText-->>Caller: error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR updates configuration, removes deprecated code review artifacts, improves concurrency handling in MCP connections, and updates documentation formatting.
- Removes Sentry console logging integration
- Adds race condition protection for MCP server connections
- Updates Cloudflare Workers compatibility date
- Cleans up documentation formatting and removes duplicate content
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| wrangler.json | Updates Cloudflare Workers compatibility_date to 2025-11-09 |
| src/lib/sentry.ts | Removes consoleIntegration and enableLogs configuration from Sentry initialization |
| docs/plan.md | Converts completed checkmarks to unchecked tasks and fixes spacing inconsistencies |
| docs/coderabbit_review01.md | Removes entire CodeRabbit review artifact file |
| convex/mcp.ts | Adds single-flight connection guard pattern to prevent race conditions in MCP server connections |
| .gitignore | Adds duplicate entry for docs/coderabbit_review01.md |
| .github/workflows/setup-github-projects_Version3.yml | Changes authentication from built-in GITHUB_TOKEN to custom MY_GITHUB_TOKEN secret |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MY_GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} | ||
| run: | | ||
| $token = $env:GH_TOKEN_SECRET | ||
| $token = $env:MY_GITHUB_TOKEN | ||
| if ([string]::IsNullOrEmpty($token)) { | ||
| Write-Host "Using GITHUB_TOKEN for authentication." | ||
| $token = $env:GITHUB_TOKEN_SECRET | ||
| Write-Error "MY_GITHUB_TOKEN secret not found. Please add it to repository secrets." | ||
| exit 1 | ||
| } | ||
| $token | gh auth login --with-token | ||
| Write-Host "Successfully authenticated gh CLI." | ||
| Write-Host "Successfully authenticated gh CLI with MY_GITHUB_TOKEN." |
There was a problem hiding this comment.
The workflow requires a custom MY_GITHUB_TOKEN secret but GITHUB_TOKEN is automatically available with the configured permissions (lines 11-13). Unless there's a specific reason to use a custom PAT (like needing access to other repositories), you should use the built-in GITHUB_TOKEN which follows the principle of least privilege and doesn't require manual secret management. Change to use secrets.GITHUB_TOKEN and update the variable name accordingly.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.github/workflows/setup-github-projects_Version3.yml(2 hunks).gitignore(1 hunks)convex/mcp.ts(2 hunks)docs/coderabbit_review01.md(0 hunks)docs/plan.md(1 hunks)src/lib/sentry.ts(0 hunks)wrangler.json(1 hunks)
💤 Files with no reviewable changes (2)
- src/lib/sentry.ts
- docs/coderabbit_review01.md
🧰 Additional context used
🧬 Code graph analysis (1)
convex/mcp.ts (2)
convex/mcp.node.ts (1)
connectLLMText(16-30)src/lib/mcp/client.ts (1)
getMCPManager(197-202)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Agent
- GitHub Check: Cloudflare Pages
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Deploying agentic-search with
|
| Latest commit: |
cc2ac84
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f8583a8a.agentic-search.pages.dev |
| Branch Preview URL: | https://test.agentic-search.pages.dev |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…issue creation process; ensure label existence, sanitize titles, and retry failed tasks. Update workflow to use GH_TOKEN for authentication and clean up .gitignore and schema definitions.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
convex/mcp.ts (1)
52-134: Connected status blocks fresh workers from ever establishing a sessionWhen
acquireConnectionLockreturns{ acquired: false, status: 'connected' }we bail out (either immediately or after a one-shot wait) without ever callingmanager.connect. That works only for the process that originally set the status. A new Convex Node worker handling this action will find its localMCPClientManagerhas no session forllm-txt, yet we still return{ success: true }. The follow-upextractTexton that worker hits the same branch and eventually callsmanager.callToolwithout a live connection, so the request fails (the manager rejects calls to unknown servers). In other words, once one instance marks the row asconnected, every other instance is permanently locked out of establishing its own MCP connection.We need to let a fresh worker rehydrate its own connection before declaring success. One straightforward fix is to treat the DB record as advisory: if
lockResult.status === 'connected'butmanager.getConnectedServers()is missingserverName, reacquire the lock (e.g. via a dedicated mutation that flips the row back toconnecting) and then runmanager.connect. Alternatively, stash an owner identifier in the connection row so only the owning worker returnsalreadyConnected, while everyone else re-enters the connect path. Without this change, multi-instance deployments will intermittently fail every call routed to a cold worker.
♻️ Duplicate comments (1)
.github/workflows/setup-github-projects_Version3.yml (1)
34-41: Restore compatibility with the built-in tokenRequiring
MY_GITHUB_TOKENmakes every run fail unless that custom secret is configured, even though GitHub already injectsGITHUB_TOKENfor this job andghonly needsGH_TOKENto be set. Use the default token so the workflow works out of the box.(docs.github.com)- name: Authenticate gh CLI shell: pwsh env: - GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }} run: | - if ([string]::IsNullOrEmpty($env:GH_TOKEN)) { - Write-Error "MY_GITHUB_TOKEN secret not found" - exit 1 - } - Write-Host "Authenticated with MY_GITHUB_TOKEN" + if ([string]::IsNullOrEmpty($env:GH_TOKEN)) { + Write-Error "GH_TOKEN was not provided by the Actions runtime" + exit 1 + } + Write-Host "Authenticated with default GITHUB_TOKEN"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
convex/_generated/api.d.tsis excluded by!**/_generated/**
📒 Files selected for processing (8)
.github/scripts/import-plan-to-issues.ps1(5 hunks).github/workflows/setup-github-projects_Version3.yml(2 hunks).gitignore(0 hunks)convex/lib/ocr/processDocument.ts(1 hunks)convex/mcp.ts(6 hunks)convex/mcp_mutations.ts(1 hunks)convex/schema.ts(1 hunks)docs/plan.md(8 hunks)
💤 Files with no reviewable changes (1)
- .gitignore
🧰 Additional context used
🧬 Code graph analysis (1)
convex/mcp.ts (2)
convex/mcp.node.ts (1)
connectLLMText(16-30)src/lib/mcp/client.ts (1)
getMCPManager(197-202)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cloudflare Pages
| await ctx.db.patch(existing._id, { | ||
| status: args.status, | ||
| lastConnectedAt: Date.now(), | ||
| ...(args.error && { error: args.error }) | ||
| }) |
There was a problem hiding this comment.
Clear stale error details when status recovers
updateConnectionStatus only patches the error field when a new error string is supplied. After a failed attempt we persist an error message; on the next successful connection we set status: 'connected' but never clear that field. Any consumer reading the record will continue to see the old error even though the status is healthy. Please explicitly null out or remove error whenever we transition to a non-failed state (e.g. include error: undefined for 'connected'/'disconnected').
🤖 Prompt for AI Agents
In convex/mcp_mutations.ts around lines 97 to 101, the patch only sets the error
field when args.error is truthy, so after a failed attempt the persisted error
remains even when status is later set to 'connected' (or other non-failed
states); modify the patch to explicitly clear the error when transitioning to a
non-failed status by including error: undefined (or null) in the update when
args.status indicates recovery (e.g., 'connected' or 'disconnected'), while
still setting error to args.error when a real error string is provided.
merge test into main
Summary by CodeRabbit
New Features
Chores
Documentation