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 @@ -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 @@ -1981,8 +1981,15 @@ class TestURLSession: LoopbackServerTest {
1981
1981
XCTFail ( " Unexpected Data Message " )
1982
1982
}
1983
1983
1984
- try await task. sendPing ( )
1985
-
1984
+ do {
1985
+ try await task. sendPing ( )
1986
+ // Server hasn't closed the connection yet
1987
+ } catch {
1988
+ // Server closed the connection before we could process the pong
1989
+ let urlError = try XCTUnwrap ( error as? URLError )
1990
+ XCTAssertEqual ( urlError. _nsError. code, NSURLErrorNetworkConnectionLost)
1991
+ }
1992
+
1986
1993
wait ( for: [ delegate. expectation] , timeout: 50 )
1987
1994
1988
1995
do {
You can’t perform that action at this time.
0 commit comments