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 {
865
865
}
866
866
}
867
867
self . receiveCompletionHandlers. removeAll ( )
868
+ for handler in self . pongCompletionHandlers {
869
+ session. delegateQueue. addOperation {
870
+ handler ( taskError)
871
+ }
872
+ }
873
+ self . pongCompletionHandlers. removeAll ( )
868
874
self . _getProtocol { urlProtocol in
869
875
self . workQueue. async {
870
876
if self . handshakeCompleted && self . state != . completed {
Original file line number Diff line number Diff line change @@ -2064,8 +2064,15 @@ class TestURLSession: LoopbackServerTest {
2064
2064
XCTFail ( " Unexpected Data Message " )
2065
2065
}
2066
2066
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
+
2069
2076
wait ( for: [ delegate. expectation] , timeout: 50 )
2070
2077
2071
2078
do {
You can’t perform that action at this time.
0 commit comments