GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): don't duplicate MCP servers started during initial reconciliation by rekram1-node · Pull Request #58349 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 23, 2026

Copy link
Copy Markdown
Member

Fixes #52741

On startup, MCP queues a launch for each enabled server. If connect() or disconnect() for that server finishes before the queued launch runs, the launch still goes ahead. That either starts a second copy (the first one's scope gets dropped while still open, so its process leaks) or brings back a server that was just disconnected.

 queued startup, under the server lock
+  if connect/disconnect already handled this server: skip
   startServer()

A skipped launch still opens the startup latch, so calls waiting on the server don't hang. I added a test that runs both the connect and disconnect orderings; both fail without the fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): don't duplicate MCP servers started during initial reconci…
298b9f0
…liation

Initial reconciliation can yield before scheduling a server's startup, letting connect() or disconnect() for that server finish first. The queued startup then spawned a second connection, leaking the first, or started a server the user had just disconnected. It now skips once the entry has left its pending state.

Fixes #52741
opencode-agent[bot]
opencode-agent Bot reviewed Oct 23, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks correct. I ran the new tests against the base: both fail there (the server initializes twice after connect(), and starts once after disconnect()). Both pass with this change, and the rest of mcp.test.ts and typecheck:tsc show no regressions. Once connect() or disconnect() has finished, the server's status is never pending again. So the guard reliably skips a queued startup, and opening the latch keeps anything waiting on the server from hanging.

Public API: unchanged.

The fix is 8 lines and the test is 47. The test also depends on a bus listener pausing reconciliation at an internal point, so it can be dropped to keep the change minimal.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
rekram1-node merged commit 8ecd6ad into dev Oct 23, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node
rekram1-node deleted the mcp-startup-race branch October 23, 2026 05:52
@github-actions github-actions Bot mentioned this pull request Oct 23, 2026
📊 AI CLI 工具社区动态日报 2026-10-23 96loveslife/big_model_radar#689
Closed
@opencodejr opencodejr Bot mentioned this pull request Oct 27, 2026
Duplicate MCP servers accumulate under one opencode process (5× mcp-reva, ~6GB RAM) #52965
Open
@opencodejr opencodejr Bot mentioned this pull request Nov 5, 2026
mcp: subprocesses accumulate under the shared service in v2.0.28 #61910
Closed
AbizardShafwan pushed a commit to AbizardShafwan/opencode that referenced this pull request Nov 9, 2026
@rekram1-node Abizard Sulaiman
fix(core): don't duplicate MCP servers started during initial reconci…
b4c81d4
…liation (anomalyco#58349)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

mcp: initial reconciliation can duplicate stdio servers

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.