CheckedContinuation never resumed in NetworkTransport send/receive on actor dealloc (Swift 6.3)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- swift
- Domain
- networking
Research direction
Start by inspecting NetworkTransport.send(_:), sendHeartbeat(), and receiveData(), focusing on their NWConnection completion handlers and CheckedContinuation usage. Reproduce the deallocation scenario described in the issue, then verify that each in-flight operation completes rather than hanging and that every continuation is resumed exactly once. PR #213 is referenced as related work.
Written by the indexing model from the issue text.
Description
Bug
When NetworkTransport is deallocated while an async send(), sendHeartbeat(), or receiveData() operation is in-flight, the CheckedContinuation inside the NWConnection completion handler is never resumed — causing a permanent deadlock.
Root Cause
The .contentProcessed completion closures capture [weak self] but do not capture continuation directly. When self becomes nil in the completion handler, the guard let self else { return } exits without resuming the continuation.
This violates Swift's CheckedContinuation contract: a continuation must be resumed exactly once. Never resuming causes the caller to hang forever. In debug builds (Swift 6.3), this produces a runtime warning.
Affected Methods
NetworkTransport.send(_ message: Data)—.contentProcessedcompletionNetworkTransport.sendHeartbeat()—.contentProcessedcompletionNetworkTransport.receiveData()—connection.receivecompletion (strong self capture inconsistency)
Reproduction
- Create a
NetworkTransportconnection - Start a
send()call - Deallocate the transport before the NWConnection completion fires
- The caller hangs indefinitely
Environment
- Swift 6.3 (also affects earlier versions, but Swift 6.3 strict concurrency makes it more visible)
- Network framework (NWConnection)
Fix
Capture continuation directly in completion closures alongside [weak self], and resume with an error in the guard's else branch. See PR #213.
- Dominant language
- Swift
- Stars
- 1.5k
- Forks
- 243
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/swift-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
All issues in modelcontextprotocol/swift-sdk
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
type: docs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
googleapis/google-cloud-swift#971 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mozilla-mobile/firefox-ios#35743 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
manaflow-ai/cmux#13417 ·