File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Sources/FoundationNetworking/URLSession Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -865,6 +865,12 @@ open class URLSessionWebSocketTask : URLSessionTask {
865865 }
866866 }
867867 self . receiveCompletionHandlers. removeAll ( )
868+ for handler in self . pongCompletionHandlers {
869+ session. delegateQueue. addOperation {
870+ handler ( taskError)
871+ }
872+ }
873+ self . pongCompletionHandlers. removeAll ( )
868874 self . _getProtocol { urlProtocol in
869875 self . workQueue. async {
870876 if self . handshakeCompleted && self . state != . completed {
Original file line number Diff line number Diff line change @@ -2064,8 +2064,15 @@ class TestURLSession: LoopbackServerTest {
20642064 XCTFail ( " Unexpected Data Message " )
20652065 }
20662066
2067- try await task. sendPing ( )
2068-
2067+ do {
2068+ try await task. sendPing ( )
2069+ // Server hasn't closed the connection yet
2070+ } catch {
2071+ // Server closed the connection before we could process the pong
2072+ let urlError = try XCTUnwrap ( error as? URLError )
2073+ XCTAssertEqual ( urlError. _nsError. code, NSURLErrorNetworkConnectionLost)
2074+ }
2075+
20692076 wait ( for: [ delegate. expectation] , timeout: 50 )
20702077
20712078 do {
You can’t perform that action at this time.
0 commit comments