Incomplete receive data is delivered as a complete WebSocket message
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- swift
- Domain
- networking
Research direction
Start at NWWebSocket.listen(connection:generation:) and inspect the NWConnection.receiveMessage callback, including its data, context, isComplete, and error values. Add regression coverage for complete, incomplete, empty, and missing-context receives, then verify that only complete data reaches the delegate while transport errors still stop the receive loop.
Written by the indexing model from the issue text.
Description
Problem
NWWebSocket.listen(connection:generation:) ignores the isComplete value from NWConnection.receiveMessage.
The completion can contain non-empty data, isComplete == false, and a transport error. The current code sends that data to receiveMessage(data:context:) before it handles the error.
A text delegate can therefore receive an incomplete UTF-8 or JSON message as a complete WebSocket message.
Apple documents receiveMessage as a complete-message receive API and provides isComplete in the callback:
https://developer.apple.com/documentation/network/nwconnection/receivemessage(completion:)
Current behavior
connection?.receiveMessage { [weak self] (data, context, _, error) in
// ...
if let data = data, !data.isEmpty, let context = context {
self.receiveMessage(data: data, context: context)
}
// The transport error is handled after data delivery.
}
Expected behavior
The library sends data to its delegate only when isComplete is true.
The existing error path continues to report the transport failure and stop the receive loop.
Proposed fix
- Read the
isCompletecallback value. - Require
isCompletebefore message delivery. - Add regression tests for complete, incomplete, empty, and missing-context receive values.
I searched the existing issues and pull requests for isComplete, receiveMessage, partial data, incomplete data, truncated data, and fragments. I found no report for this case.
- Dominant language
- Swift
- Stars
- 161
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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 pusher/NWWebSocket
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
pusher/NWWebSocket#65 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
pusher/NWWebSocket#48 · 1 comment ·
-
enhancement question
Difficulty 5/5 Over a week Newbie friendliness 20/100
pusher/NWWebSocket#22 · 2 comments ·
All issues in pusher/NWWebSocket
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 ·