Skip to content

Commit 85f4c77

Browse files
committed
Surface setup task errors
1 parent 2ea027d commit 85f4c77

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

FirebaseAI/Sources/Types/Internal/Live/LiveSessionService.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ actor LiveSessionService {
114114
///
115115
/// Seperated into its own function to make it easier to surface a way to call it seperately when
116116
/// resuming the same session.
117-
func connect() {
117+
func connect() async throws {
118118
close()
119-
// we launch the setup task in a seperate task to avoid blocking the parent context
119+
// we launch the setup task in a seperate task to allow us to cancel it via close
120120
setupTask = Task { [weak self] in
121121
// we need a continuation to surface that the setup is complete, while still allowing us to
122122
// listen to the server
@@ -128,6 +128,8 @@ actor LiveSessionService {
128128
}
129129
}
130130
}
131+
132+
try await setupTask.value
131133
}
132134

133135
/// Cancel any running tasks and close the websocket.

FirebaseAI/Sources/Types/Public/Live/LiveGenerativeModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final class LiveGenerativeModel {
6767
requestOptions: requestOptions
6868
)
6969

70-
await service.connect()
70+
try await service.connect()
7171

7272
return LiveSession(service: service)
7373
}

0 commit comments

Comments
 (0)