File tree 2 files changed +15
-2
lines changed
Sources/FoundationNetworking/URLSession
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -849,6 +849,12 @@ open class URLSessionWebSocketTask : URLSessionTask {
849
849
}
850
850
}
851
851
self . receiveCompletionHandlers. removeAll ( )
852
+ for handler in self . pongCompletionHandlers {
853
+ session. delegateQueue. addOperation {
854
+ handler ( taskError)
855
+ }
856
+ }
857
+ self . pongCompletionHandlers. removeAll ( )
852
858
self . _getProtocol { urlProtocol in
853
859
self . workQueue. async {
854
860
if self . handshakeCompleted && self . state != . completed {
Original file line number Diff line number Diff line change @@ -1893,8 +1893,15 @@ class TestURLSession: LoopbackServerTest {
1893
1893
XCTFail ( " Unexpected Data Message " )
1894
1894
}
1895
1895
1896
- try await task. sendPing ( )
1897
-
1896
+ do {
1897
+ try await task. sendPing ( )
1898
+ // Server hasn't closed the connection yet
1899
+ } catch {
1900
+ // Server closed the connection before we could process the pong
1901
+ let urlError = try XCTUnwrap ( error as? URLError )
1902
+ XCTAssertEqual ( urlError. _nsError. code, NSURLErrorNetworkConnectionLost)
1903
+ }
1904
+
1898
1905
wait ( for: [ delegate. expectation] , timeout: 50 )
1899
1906
1900
1907
do {
You can’t perform that action at this time.
0 commit comments