Skip to content

Fix NetworkTransport continuation crash by bumping swift-sdk - #149

Closed
peters438 wants to merge 1 commit into
mattt:mainfrom
peters438:fix/bump-swift-sdk-continuation-crash
Closed

peters438 wants to merge 1 commit into
mattt:mainfrom
peters438:fix/bump-swift-sdk-continuation-crash

Conversation

@peters438

Copy link
Copy Markdown

Summary

  • Bumps modelcontextprotocol/swift-sdk from 106167b to 973b46b (V0.11.x), which rewrites NetworkTransport.connect() to use AsyncStream instead of withCheckedThrowingContinuation with a resettable boolean guard
  • Updates ServerController.swift for the new Tool.Content API (label changes to text/image/audio enum cases, inputSchema type change from JSONSchema to Value)
  • Disables reconnection and heartbeats in MCPConnectionManager since iMCP accepts fresh per-client connections

Problem

The pinned swift-sdk revision had a bug where connectionContinuationResumed (an instance-level boolean) was reset to false on each connect() call. If NWConnection state transitions fired concurrently, old Tasks from previous state handlers could double-resume stale continuations, causing SWIFT TASK CONTINUATION MISUSE crashes. This made iMCP crash immediately on client connection (macOS Sequoia 15.7.3 and Tahoe).

Relates to #136.

Test plan

  • Builds successfully with xcodebuild -scheme iMCP -configuration Debug build
  • Passes swift format lint --strict --recursive .
  • App launches and stays alive in the menu bar (no continuation crash)
  • MCP server accepts client connections via stdio transport
  • CI passes

🤖 Generated with Claude Code

The pinned swift-sdk revision (106167b) had a bug in
NetworkTransport.connect() where a resettable instance-level boolean
guarded continuation resume. Concurrent state transitions could
double-resume or leak continuations, crashing the app on connect.

The upstream swift-sdk (973b46b, V0.11.x) rewrote connect() to use
AsyncStream, eliminating the continuation entirely. This bumps the
pin and updates ServerController.swift for the new Tool.Content API
(text/image/audio label changes, inputSchema JSONSchema -> Value).

Also disables reconnection and heartbeats in MCPConnectionManager
since iMCP accepts fresh connections per client rather than
maintaining long-lived ones.

Fixes mattt#136

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant