Skip to content

Commit

Permalink
fix linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Jan 17, 2025
1 parent d800a95 commit b63bd61
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
8 changes: 7 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ let package = Package(
"Supabase",
"TestHelpers",
],
resources: [.process("Fixtures")]
resources: [
.process("Fixtures"),
.process("supabase"),
]
),
.target(
name: "PostgREST",
Expand Down Expand Up @@ -149,6 +152,9 @@ let package = Package(
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
"Storage",
],
resources: [
.copy("sadcat.jpg")
]
),
.target(
Expand Down
23 changes: 14 additions & 9 deletions Sources/Realtime/WebSocket/URLSessionWebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ final class URLSessionWebSocket: WebSocket {
}

private func _scheduleReceive() {
_task.receive { [weak self] result in
Task {
let result = await Result { try await _task.receive() }
switch result {
case .success(let value): self?._handleMessage(value)
case .failure(let error): self?._closeConnectionWithError(error)
case .success(let value): _handleMessage(value)
case .failure(let error): _closeConnectionWithError(error)
}
}
}
Expand Down Expand Up @@ -168,9 +169,11 @@ final class URLSessionWebSocket: WebSocket {
return
}

_task.send(.string(text)) { [weak self] error in
if let error {
self?._closeConnectionWithError(error)
Task {
do {
try await _task.send(.string(text))
} catch {
_closeConnectionWithError(error)
}
}
}
Expand Down Expand Up @@ -198,9 +201,11 @@ final class URLSessionWebSocket: WebSocket {
return
}

_task.send(.data(binary)) { [weak self] error in
if let error {
self?._closeConnectionWithError(error)
Task {
do {
try await _task.send(.data(binary))
} catch {
_closeConnectionWithError(error)
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion Tests/IntegrationTests/RealtimeIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ final class RealtimeIntegrationTests: XCTestCase {

let client = SupabaseClient(
supabaseURL: URL(string: DotEnv.SUPABASE_URL)!,
supabaseKey: DotEnv.SUPABASE_ANON_KEY
supabaseKey: DotEnv.SUPABASE_ANON_KEY,
options: SupabaseClientOptions(
auth: SupabaseClientOptions.AuthOptions(
storage: InMemoryLocalStorage()
)
)
)

override func setUp() {
Expand Down

0 comments on commit b63bd61

Please sign in to comment.