Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close a WebSocketTask if it completes with an error without closing p…
…roperly https://bugs.webkit.org/show_bug.cgi?id=274003 rdar://110487778 Reviewed by Brady Eidson. If the TCP connection has an error but we have not received a close frame, then CFNetwork will call didCompleteWithError but won't call the completion block of receiveMessageWithCompletionHandler. This is strange, but to make our interface with CFNetwork more robust, close the WebSocket in this case if it hasn't already been closed. WebSocketTask::didClose will ignore this call if it has already been closed. Unfortunately, the API doesn't exist to make a unit test for this. In attempting to make a unit test, I filed rdar://127883777 which, when resolved will allow us to test cases similar to this. That radar shows that future work is still to be done in this area, but manual testing verifies this fixes the issue in the original radar of rdar://110487778 There are 3 ways a WebSocketTask can close: 1. receiveMessageWithCompletionHandler completion block can be called with an error 2. URLSession:webSocketTask:didCloseWithCode:reason: can be called 3. URLSession:task:didCompleteWithError: can be called It is an error for didCompleteWithError to be called before another call has closed the WebSocket, so this change calling didClose whether error is null or not is correct. * Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]): Canonical link: https://commits.webkit.org/278623@main
- Loading branch information