Skip to content

Fix resource update crash after client disconnect#1218

Open
stephenreid321 wants to merge 1 commit into
mongodb-js:mainfrom
stephenreid321:fix/resource-update-disconnected-transport
Open

Fix resource update crash after client disconnect#1218
stephenreid321 wants to merge 1 commit into
mongodb-js:mainfrom
stephenreid321:fix/resource-update-disconnected-transport

Conversation

@stephenreid321

Copy link
Copy Markdown

Summary

  • Skip resource update notifications once the MCP server transport is disconnected.
  • Catch/log resource update notification failures so a late subscription update cannot become an unhandled rejection.
  • Add unit coverage for disconnected and late-failing resource update paths.

Context

When a Streamable HTTP client subscribes to debug://mongodb, lets the session go idle, and the session closes, reactive resources can still emit sendResourceUpdated. In that state the MCP SDK throws Error: Not connected; because the promise was intentionally discarded, the rejection can terminate Node and restart hosted services.

Observed stack shape:

Error: Not connected
    at Server.notification (.../@modelcontextprotocol/sdk/dist/esm/shared/protocol.js:791:19)
    at Server.sendResourceUpdated (.../@modelcontextprotocol/sdk/dist/esm/server/index.js:423:21)
    at Server.sendResourceUpdated (.../mongodb-mcp-server/dist/esm/server.js:121:40)
    at DebugResource.triggerUpdate (.../mongodb-mcp-server/dist/esm/resources/resource.js:38:26)

Validation

  • npx --yes prettier@3.8.1 --check src/server.ts tests/unit/server.test.ts
  • Secret scan of changed snippets: no secrets found

@stephenreid321 stephenreid321 requested a review from a team as a code owner June 1, 2026 17:44
@stephenreid321 stephenreid321 requested review from Luke-Sanderson and removed request for a team June 1, 2026 17:44
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

This PR has gone 30 days without any activity and meets the project's definition of "stale". This will be auto-closed if there is no new activity over the next 30 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant