Skip to content

Commit cf75d83

Browse files
committed
Cancel and invalidate the URLSession task in the delegate callback test
The WebSocket task was created but never resumed or cancelled, which aborts (SIGABRT) when URLSession deallocates it on CI.
1 parent 3011d10 commit cf75d83

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Tests/HAURLSessionWebSocketEngine.test.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ internal class HAURLSessionWebSocketEngineTests: XCTestCase {
118118
engine.register(delegate: delegate)
119119

120120
let session = URLSession(configuration: .ephemeral)
121+
defer { session.invalidateAndCancel() }
121122
let task = try session.webSocketTask(with: XCTUnwrap(URL(string: "wss://example.com/api/websocket")))
123+
task.cancel(with: .normalClosure, reason: nil)
122124

123125
engine.urlSession(session, webSocketTask: task, didOpenWithProtocol: "chat")
124126
engine.urlSession(session, webSocketTask: task, didCloseWith: .goingAway, reason: Data("bye".utf8))

0 commit comments

Comments
 (0)