File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,9 @@ actor LiveSessionService {
114
114
///
115
115
/// Seperated into its own function to make it easier to surface a way to call it seperately when
116
116
/// resuming the same session.
117
- func connect( ) {
117
+ func connect( ) async throws {
118
118
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
120
120
setupTask = Task { [ weak self] in
121
121
// we need a continuation to surface that the setup is complete, while still allowing us to
122
122
// listen to the server
@@ -128,6 +128,8 @@ actor LiveSessionService {
128
128
}
129
129
}
130
130
}
131
+
132
+ try await setupTask. value
131
133
}
132
134
133
135
/// Cancel any running tasks and close the websocket.
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public final class LiveGenerativeModel {
67
67
requestOptions: requestOptions
68
68
)
69
69
70
- await service. connect ( )
70
+ try await service. connect ( )
71
71
72
72
return LiveSession ( service: service)
73
73
}
You can’t perform that action at this time.
0 commit comments