Improve MCP client connection resilience with Promise.allSettled#374
Merged
threepointone merged 6 commits intocloudflare:mainfrom Jul 31, 2025
Conversation
Replace Promise.all with Promise.allSettled in MCPClientConnection.init() to handle partial capability failures gracefully. This prevents entire connection failures when individual MCP server capabilities are unavailable. Changes: - Use Promise.allSettled for capability discovery operations - Log failed capabilities with console.error instead of throwing - Set fallback values for failed capabilities (empty arrays/undefined) - Maintain connection ready state even with partial failures 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <noreply@opencode.ai>
🦋 Changeset detectedLatest commit: dc1c450 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
@laulauland can you please take a look at failed build? could we add some tests for this? |
…mentation Resolve type inference issues by destructuring Promise.allSettled results directly instead of using a mixed-type operations array. This allows TypeScript to properly infer the individual result types. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <noreply@opencode.ai>
Contributor
Author
|
Thanks @threepointone for the changeset! I pushed a little test for the client connection as well. |
threepointone
approved these changes
Jul 31, 2025
Contributor
threepointone
left a comment
There was a problem hiding this comment.
Looks good now, thanks so much for the PR! landing
Merged
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.
Small change kinda addressing #320
Instead of failing the connection this would provide a fallback and log the error that registering a capability failed.
Another alternative would be:
try..catchon thePromise.allthis.connectionState = failedand exit the functionChanges: